CI: Adapt check to changed Nix output #318
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'CI' | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build-nix: | |
name: Build Nix package | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
- macos-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Nix | |
uses: cachix/install-nix-action@v26 | |
with: | |
extra_nix_config: | | |
experimental-features = nix-command flakes recursive-nix | |
- name: Verify flake.lock is up-to-date | |
run: | | |
nix flake lock --no-update-lock-file | |
- name: Build package | |
run: | | |
nix build -L | |
check: | |
name: Run our Action | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
fetch-depth: | |
- 0 # all history | |
- 1 # shallow clone | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: ${{ matrix.fetch-depth }} | |
- name: Install Nix | |
uses: cachix/install-nix-action@v26 | |
with: | |
extra_nix_config: | | |
experimental-features = nix-command flakes recursive-nix | |
- name: 'Setup Cachix' | |
uses: cachix/cachix-action@v14 | |
with: | |
name: wurzelpfropf | |
authToken: '${{ secrets.CACHIX_AUTH_TOKEN_PUBLIC }}' | |
- name: Run Action (packages) | |
uses: ./ | |
with: | |
packages: 'hello' | |
- name: Run hello | |
run: | | |
hello | |
- name: Run Action (expr) | |
uses: ./ | |
with: | |
expr: 'pkgs.figlet' | |
- name: Run Action (packages + expr) | |
uses: ./ | |
with: | |
packages: 'cowsay' | |
expr: 'pkgs.ponysay' | |
- name: Run `cowsay` and `ponysay` | |
run: | | |
cowsay "Muhhhh" | |
ponysay "Hüüühhhhh" | |
- name: Run Action (GitHub Flake with default package) | |
uses: ./ | |
with: | |
packages: 'github:yaxitech/ragenix' | |
- name: Run `ragenix` | |
run: | | |
ragenix --help | |
- name: Run Action (package with inputs-from) | |
uses: ./ | |
id: 'inputs-from-jq' | |
with: | |
packages: 'jq' | |
inputs-from: 'github:yaxitech/ragenix' | |
- name: Verify `nixpkgs` from `github:yaxitech/ragenix` | |
run: | | |
nix profile list --profile '${{ steps.inputs-from-jq.outputs.nix_profile_path }}' | |
rev=$(nix flake metadata --json "github:yaxitech/ragenix" | jq -r .locks.nodes.nixpkgs.locked.rev) | |
nix profile list --profile '${{ steps.inputs-from-jq.outputs.nix_profile_path }}' --json | jq -r '.elements.jq.url' | grep -q "$rev" | |
- name: List installed packages | |
run: | |
nix profile list --profile "$STATE_NIX_PROFILE_TMPDIR"/.nix-profile | |
- name: Run figlet | |
run: | | |
figlet WURZELPFROPF | |
build: | |
name: Build bundled action | |
if: github.event_name == 'push' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
# We need a full checkout for a Git diff | |
fetch-depth: 0 | |
- name: Install Nix | |
uses: cachix/install-nix-action@v26 | |
with: | |
extra_nix_config: | | |
experimental-features = nix-command flakes recursive-nix | |
- name: Install job dependencies | |
uses: ./ | |
with: | |
expr: 'pkgs.python3.withPackages (ps: [ps.GitPython])' | |
- name: Build action | |
run: | | |
python .github/steps/build_action.py | |
coverage: | |
if: github.event_name == 'push' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
# We need a full checkout for the tests | |
fetch-depth: 0 | |
- name: Install Nix | |
uses: cachix/install-nix-action@v26 | |
with: | |
extra_nix_config: | | |
experimental-features = nix-command flakes recursive-nix | |
- name: Run tests with coverage | |
run: | | |
nix develop -c npm install | |
nix develop -c npm run coverage | |
- name: Install job dependencies | |
if: github.ref == 'refs/heads/main' | |
uses: ./ | |
with: | |
expr: | | |
pkgs.python3.withPackages (ps: with ps; [ ghp-import ]) | |
- name: Push badge | |
if: github.ref == 'refs/heads/main' | |
run: | | |
python .github/steps/push_badge.py |