Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: introduce nixf-tidy-action #1469

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/nixf-tidy-action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: nixf-tidy code linter

on:
[ pull_request ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer YAML syntax to JSON-style

Also, I'm not sure pull_request is the right event here. That runs whenever a PR is opened, edited, reviewed, etc (see "activity types").

Instead, we'd want this to run whenever a branch is updated (push).

We could use branches-ignore to prevent running on main and nixos-*, but IMO I don't see an issue with having the CI on these branches too.

Note if the action expects github.event.pull_request.head.sha, this'll be missing when using on.push. Instead github.sha or GITHUB_SHA should be used for non-pr events.

Suggested change
[ pull_request ]
push

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I'm not sure pull_request is the right event here. That runs whenever a PR is opened, edited, reviewed, etc (see "activity types").

I haven't test it exactly for events other than "pull_request", maybe I should update the action itself then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I'm not sure pull_request is the right event here. That runs whenever a PR is opened, edited, reviewed, etc (see "activity types").

I think some of my assumptions were off here. The pull_request event does get triggered by a bunch of stuff, but pushes to a PR branch don't always seem to trigger the push event...


jobs:
nixf-tidy:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false

if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
inclyc marked this conversation as resolved.
Show resolved Hide resolved
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
extra_nix_config: |
trusted-public-keys = nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
substituters = https://nix-community.cachix.org https://cache.nixos.org/
- run: nix profile install github:nix-community/nixd#nixd
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this should be the responsibility of the nixf-tidy-action action.

Is there some technical reason why we need to install the action's dependency in our workflow?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this should be the responsibility of the nixf-tidy-action action.

Is there some technical reason why we need to install the action's dependency in our workflow?

Thanks, I just wrote nixf-tidy-action action in purely typescript. Thus I think it is more elegant to handle dependencies in nix?

(Otherwise these installation should be performed in "js" exec, looks bad!)

- uses: inclyc/nixf-tidy-action@v1
Loading