Skip to content

Commit

Permalink
flake: get rid of hash checking
Browse files Browse the repository at this point in the history
the build will fail if the hashes are not up to date, so there's no reason to check them.
  • Loading branch information
NyCodeGHG committed Sep 26, 2023
1 parent af77def commit 16821f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 80 deletions.
9 changes: 4 additions & 5 deletions .github/allowed-nix-update-users.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
github:
let
github: let
commenter = github.event.sender;
allowlist = {
# See id on https://api.github.com/users/<username>
Expand All @@ -13,8 +12,8 @@ let
(builtins.attrValues allowlist) ++ [github.event.issue.user.id]
);
in
if isAllowedUser then
if isAllowedUser
then
builtins.trace "The user '${commenter.login}' is allowed to run the command. ✅"
true
else
builtins.throw "The user '${commenter.login}' is not allowed to run the command. ❌"
else builtins.throw "The user '${commenter.login}' is not allowed to run the command. ❌"
75 changes: 0 additions & 75 deletions .github/workflows/nix-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,84 +3,9 @@ on:
push:
pull_request:
jobs:
check-hashes:
name: Ensure Nix Hashes are up-to-date
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check if relevant files changed
shell: bash
id: check
run: |
# most sane regex
# checks if one of these files/directories has been touched
# - package.json
# - package-lock.json
# - nix/
# - composer.json
# - composer.lock
if [ -n "$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -P '^(?:package(?:-lock)?\.json$|nix\/|composer\.(?:json|lock)$)')" ]; then
echo "File(s) changed so this job runs"
else
echo "no files changed so we exit neutrally"
echo "skip=true" >> "$GITHUB_OUTPUT"
fi
- name: Install nix
if: "steps.check.outputs.skip != 'true'"
uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable
# - uses: cachix/cachix-action@v12
# with:
# name: trawelling
# authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- name: Update generated files
if: "steps.check.outputs.skip != 'true'"
run: nix develop --impure .#ci --command "update-nix-package-deps"

- name: Check if up-to-date
shell: bash
id: check
if: "steps.check.outputs.skip != 'true'"
run: |
if [[ ! -z $(git status -s) ]]; then
git status
echo "up-to-date=false" >> "$GITHUB_OUTPUT"
fi
- name: Find Comment
uses: peter-evans/find-comment@v2
if: "steps.check.outputs.skip != 'true' && github.event_name == 'pull_request' && steps.check.outputs.up-to-date == 'false'"
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: The composer or npm dependencies are out of sync with the generated nix files.

- name: Create comment
if: "steps.check.outputs.skip != 'true' && steps.fc.outputs.comment-id == '' && github.event_name == 'pull_request' && steps.check.outputs.up-to-date == 'false'"
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
The composer or npm dependencies are out of sync with the generated nix files.
Please update the files by either running the `update-nix-package-dep` script locally
or let GitHub actions do it by running `/nix-update`.
*This comment was written by a bot!* 🤖
- name: Fail Build
if: "steps.check.outputs.skip != 'true' && steps.check.outputs.up-to-date == 'false'"
shell: bash
run: exit 1

build:
name: Build Package
runs-on: ubuntu-latest
needs:
- check-hashes
steps:
- uses: actions/checkout@v3
- name: Install nix
Expand Down

0 comments on commit 16821f8

Please sign in to comment.