Skip to content

Commit 32535c5

Browse files
authored
Merge pull request #33 from DeterminateSystems/graham/fh-870-ghacv2-make-fhca-a-composite-action-like-determinate-nix
Graham/fh 870 ghacv2 make fhca a composite action like determinate nix
2 parents c4d270b + 203f240 commit 32535c5

34 files changed

+839
-101517
lines changed

.envrc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
if ! has nix_direnv_version || ! nix_direnv_version 2.1.1; then
2-
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.1.1/direnvrc" "sha256-b6qJ4r34rbE23yWjMqbmu3ia2z4b2wIlZUksBke/ol0="
3-
fi
4-
5-
use_flake
1+
use flake

.eslintrc.json

Lines changed: 0 additions & 75 deletions
This file was deleted.

.gitattributes

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/cache-test.sh

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,8 @@ is_gh_throttled() {
1515
}
1616

1717
# Check that the action initialized correctly.
18-
if [ "$EXPECT_FLAKEHUB" == "true" ]; then
19-
grep 'FlakeHub cache is enabled' "${log}"
20-
grep 'Using cache' "${log}"
21-
else
22-
grep 'FlakeHub cache is disabled' "${log}" \
23-
|| grep 'FlakeHub: cache initialized failed' "${log}"
24-
fi
18+
grep 'FlakeHub cache is enabled' "${log}"
19+
grep 'Using cache' "${log}"
2520

2621
if [ "$EXPECT_GITHUB_CACHE" == "true" ]; then
2722
grep 'GitHub Action cache is enabled' "${log}"
@@ -33,19 +28,17 @@ fi
3328
outpath=$(nix-build .github/workflows/cache-tester.nix --argstr seed "$seed")
3429

3530
# Wait until it has been pushed succesfully.
36-
if [ "$EXPECT_FLAKEHUB" == "true" ]; then
37-
found=
38-
for ((i = 0; i < 60; i++)); do
39-
sleep 1
40-
if grep "$(basename "${outpath}")" "${log}"; then
41-
found=1
42-
break
43-
fi
44-
done
45-
if [[ -z $found ]]; then
46-
echo "FlakeHub push did not happen." >&2
47-
exit 1
48-
fi
31+
found=
32+
for ((i = 0; i < 60; i++)); do
33+
sleep 1
34+
if grep "$(basename "${outpath}")" "${log}"; then
35+
found=1
36+
break
37+
fi
38+
done
39+
if [[ -z $found ]]; then
40+
echo "FlakeHub push did not happen." >&2
41+
exit 1
4942
fi
5043

5144
if [ "$EXPECT_GITHUB_CACHE" == "true" ]; then
@@ -68,10 +61,8 @@ fi
6861

6962

7063

71-
if [ "$EXPECT_FLAKEHUB" == "true" ]; then
72-
# Check the FlakeHub binary cache to see if the path is really there.
73-
nix path-info --store "${flakehub_binary_cache}" "${outpath}"
74-
fi
64+
# Check the FlakeHub binary cache to see if the path is really there.
65+
nix path-info --store "${flakehub_binary_cache}" "${outpath}"
7566

7667
if [ "$EXPECT_GITHUB_CACHE" == "true" ] && ! is_gh_throttled; then
7768
# Check the GitHub binary cache to see if the path is really there.
@@ -91,16 +82,12 @@ echo "-------"
9182
echo "Trying to substitute the build again..."
9283
echo "if it fails, the cache is broken."
9384

94-
if [ "$EXPECT_FLAKEHUB" == "true" ]; then
95-
# Check the FlakeHub binary cache to see if the path is really there.
96-
nix path-info --store "${flakehub_binary_cache}" "${outpath}"
97-
fi
85+
# Check the FlakeHub binary cache to see if the path is really there.
86+
nix path-info --store "${flakehub_binary_cache}" "${outpath}"
9887

9988
if [ "$EXPECT_GITHUB_CACHE" == "true" ] && ! is_gh_throttled; then
10089
# Check the FlakeHub binary cache to see if the path is really there.
10190
nix path-info --store "${gha_binary_cache}" "${outpath}"
10291
fi
10392

104-
if ([ "$EXPECT_GITHUB_CACHE" == "true" ] && ! is_gh_throttled) || [ "$EXPECT_FLAKEHUB" == "true" ]; then
105-
nix-store --realize -vvvvvvvv "$outpath"
106-
fi
93+
nix-store --realize -vvvvvvvv "$outpath"

.github/workflows/ci.yml

Lines changed: 31 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,13 @@
1-
name: CI
2-
31
on:
42
merge_group:
53
pull_request:
64
push:
75
branches: [main]
86

97
jobs:
10-
build:
11-
name: Build
12-
runs-on: ubuntu-22.04
13-
steps:
14-
- uses: actions/checkout@v4
15-
- name: Install Nix
16-
uses: DeterminateSystems/nix-installer-action@main
17-
- uses: DeterminateSystems/flakehub-cache-action@main
18-
- name: Check shell scripts
19-
run: |
20-
nix develop --command shellcheck ./.github/workflows/cache-test.sh
21-
- uses: DeterminateSystems/nix-installer-action@main
22-
- name: Install pnpm dependencies
23-
run: nix develop --command pnpm install
24-
- name: Check formatting
25-
run: nix develop --command pnpm run check-fmt
26-
- name: Lint
27-
run: nix develop --command pnpm run lint
28-
- name: Build
29-
run: nix develop --command pnpm run build
30-
- name: Package
31-
run: nix develop --command pnpm run package
32-
- run: git status --porcelain=v1
33-
- run: git diff --exit-code
34-
35-
test-no-nix:
36-
needs: build
37-
name: "Test: Nix not installed"
38-
runs-on: ubuntu-22.04
39-
permissions:
40-
id-token: "write"
41-
contents: "read"
42-
env:
43-
ACTIONS_STEP_DEBUG: true
44-
steps:
45-
- uses: actions/checkout@v4
46-
- name: Cache the store
47-
uses: ./
48-
with:
49-
_internal-strict-mode: true
50-
51-
run-x86_64-linux-untrusted:
52-
needs: build
53-
name: Run x86_64-linux, Untrusted
54-
runs-on: ubuntu-22.04
55-
permissions:
56-
id-token: "write"
57-
contents: "read"
58-
env:
59-
ACTIONS_STEP_DEBUG: true
60-
steps:
61-
- uses: actions/checkout@v4
62-
- name: Install Nix
63-
uses: DeterminateSystems/nix-installer-action@main
64-
with:
65-
flakehub: true
66-
extra-conf: |
67-
narinfo-cache-negative-ttl = 0
68-
trusted-users = root
69-
- name: Cache the store
70-
uses: ./
71-
with:
72-
_internal-strict-mode: true
73-
748
run-systems:
75-
if: github.event_name == 'merge_group'
76-
needs: build
77-
name: "Test: ${{ matrix.systems.nix-system }} gha:${{matrix.use-gha-cache}},fhc:${{matrix.use-flakehub}},id:${{matrix.id-token}},determinate:${{matrix.determinate}}"
9+
# if: github.event_name == 'merge_group'
10+
name: "Test: ${{ matrix.systems.nix-system }}"
7811
runs-on: "${{ matrix.systems.runner }}"
7912
permissions:
8013
id-token: "write"
@@ -84,8 +17,6 @@ jobs:
8417
strategy:
8518
fail-fast: false
8619
matrix:
87-
determinate: [true, false]
88-
id-token: ["write", "none"]
8920
systems:
9021
- nix-system: "aarch64-darwin"
9122
runner: "macos-latest"
@@ -98,27 +29,50 @@ jobs:
9829
steps:
9930
- uses: actions/checkout@v4
10031
- name: Install Nix on ${{ matrix.systems.nix-system }} system
101-
uses: DeterminateSystems/nix-installer-action@main
32+
uses: DeterminateSystems/determinate-nix-action@main
10233
with:
103-
_internal-obliterate-actions-id-token-request-variables: ${{ matrix.id-token == 'none' }}
104-
determinate: ${{ matrix.determinate }}
10534
extra-conf: |
10635
narinfo-cache-negative-ttl = 0
10736
- name: Cache the store
10837
uses: ./
10938
with:
11039
_internal-strict-mode: true
111-
_internal-obliterate-actions-id-token-request-variables: ${{ matrix.id-token == 'none' }}
11240
- name: Check the cache for liveness
11341
env:
114-
EXPECT_FLAKEHUB: ${{ toJson(matrix.id-token == 'write') }}
11542
EXPECT_GITHUB_CACHE: ${{ toJson(false) }}
11643
run: |
11744
.github/workflows/cache-test.sh
11845
46+
lint:
47+
name: Build
48+
runs-on: ubuntu-latest
49+
permissions:
50+
id-token: "write"
51+
contents: "read"
52+
steps:
53+
- uses: actions/checkout@v4
54+
- uses: DeterminateSystems/determinate-nix-action@v3
55+
- uses: ./.
56+
- run: nix develop -c typos
57+
if: success() || failure()
58+
- run: nix develop -c ruff check
59+
if: success() || failure()
60+
- run: nix develop -c ruff format --diff
61+
if: success() || failure()
62+
- run: nix develop -c shellcheck ./tools/*.sh
63+
if: success() || failure()
64+
- name: Regenerate the README to make sure it is unchanged
65+
run: nix develop -c ./tools/generate.sh
66+
if: success() || failure()
67+
- name: Assert no changes were made
68+
run: git diff --exit-code
69+
if: success() || failure()
70+
11971
success:
12072
runs-on: ubuntu-latest
121-
needs: run-systems
73+
needs:
74+
- run-systems
75+
- lint
12276
if: always()
12377
steps:
12478
- run: "true"

.github/workflows/flakehub-cache.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
on:
2+
workflow_dispatch:
3+
inputs:
4+
reference-id:
5+
type: string
6+
required: true
7+
version:
8+
type: string
9+
required: true
10+
11+
concurrency:
12+
group: ${{ github.workflow }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
propose-release:
17+
uses: DeterminateSystems/propose-release/.github/workflows/workflow.yml@main
18+
permissions:
19+
id-token: "write"
20+
contents: "write"
21+
pull-requests: write
22+
with:
23+
reference-id: ${{ inputs.reference-id }}
24+
version: ${{ inputs.version }}
25+
extra-commands-early: |
26+
nix develop -c ./tools/update-state.sh "v$VERSION"
27+
git diff || true
28+
git commit -m "Update the state.json for v$VERSION" ./tools/state.json
29+
nix develop -c ./tools/generate.sh
30+
git commit -m "Update README.md and action.yml for v$VERSION" README.md action.yml
31+
echo "Checking there is no remaining diff..."
32+
git diff --exit-code

0 commit comments

Comments
 (0)