File tree Expand file tree Collapse file tree 2 files changed +16
-13
lines changed Expand file tree Collapse file tree 2 files changed +16
-13
lines changed Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
3
3
# Build the webring at a particular commit hash and put it in the `/dev/shm/webring-ci` directory.
4
- #
4
+ #
5
5
# The working directory is expected to be the highest directory of the git repo (~/webring)
6
6
7
7
set -e
8
8
9
9
if [ $# -ne 1 ]; then
10
- echo Expected one argument for the commit hash
10
+ echo Error: expected one argument for the commit hash >&2
11
11
exit 1
12
12
fi
13
13
14
- HASH=$1
14
+ HASH=" $1 "
15
15
16
16
# Set up the testing directory in tmpfs
17
17
18
18
CI_PATH=/dev/shm/webring-ci
19
19
20
- # Create the directory if it's not already created
21
- if ! [ -d $CI_PATH ]; then
22
- # Prevent other users from deleting/modifying our directory
23
- mkdir $CI_PATH --mode=700
20
+ # Ensure there isn't a deployment already running
21
+ if [ -d " $CI_PATH " ]; then
22
+ echo " Error: $CI_PATH exists. Is there a CI job already running? " >&2
23
+ exit 1
24
24
fi
25
25
26
+ # Prevent other users from deleting/modifying our directory
27
+ mkdir " $CI_PATH " --mode=700
28
+
26
29
# Checkout the commit into the testing directory
27
30
# Use `--work-tree` to copy the code into the testing directory instead of the deployment directory. This doesn't copy `.git`.
28
- git fetch --all
29
- git -- work-tree $CI_PATH checkout $HASH -- .
30
- cd $CI_PATH
31
+ git fetch origin " $HASH "
32
+ git -c advice.detachedHead=false -- work-tree " $CI_PATH " restore --source= " $HASH " --worktree -- :/
33
+ cd " $CI_PATH "
31
34
32
35
# Build the flake
33
36
nix build
Original file line number Diff line number Diff line change 5
5
set -e
6
6
7
7
if [ $# -ne 1 ]; then
8
- echo Expected one argument for the commit hash
8
+ echo Error: expected one argument for the commit hash >&2
9
9
exit 1
10
10
fi
11
11
12
12
HASH=$1
13
13
14
14
# Fetch and checkout the commit
15
- git fetch --all
16
- git checkout $HASH
15
+ git fetch origin " $HASH "
16
+ git -c advice.detachedHead=false checkout --force " $HASH "
17
17
18
18
# Reload home manager — Automatically rebuilds the webring and restarts the systemd unit.
19
19
home-manager switch
You can’t perform that action at this time.
0 commit comments