forked from mirrors/gomod2nix
actions: Generate github actions matrix dynamically
This commit is contained in:
parent
d5d8bbba2d
commit
98ffbabcfa
1 changed files with 26 additions and 10 deletions
36
.github/workflows/ci.yml
vendored
36
.github/workflows/ci.yml
vendored
|
@ -19,16 +19,32 @@ jobs:
|
|||
- name: Check format
|
||||
run: nix-shell --run 'nixpkgs-fmt --check .'
|
||||
|
||||
build:
|
||||
list-jobs:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v17
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-unstable
|
||||
- id: set-matrix
|
||||
run: |
|
||||
set -euo pipefail
|
||||
matrix="$(go run tests/run.go list | jq --raw-input --slurp -rcM '{attr: split("\n")[:-1], os: ["ubuntu-latest"]}')"
|
||||
echo "::set-output name=matrix::$matrix"
|
||||
|
||||
builds:
|
||||
needs: list-jobs
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
nixpkgs_version: ["master"]
|
||||
# os: [ubuntu-latest, macos-latest]
|
||||
env:
|
||||
NIX_PATH: "nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz"
|
||||
matrix: ${{fromJSON(needs.list-jobs.outputs.matrix)}}
|
||||
steps:
|
||||
- uses: cachix/install-nix-action@v12
|
||||
- uses: actions/checkout@v1
|
||||
- run: nix-shell --run 'make'
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v17
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-unstable
|
||||
- name: "Build gomod2nix"
|
||||
run: nix-shell --run "go build"
|
||||
- name: "Run test: ${{ matrix.attr }}"
|
||||
run: nix-shell --run "go run tests/run.go run ${{ matrix.attr }}"
|
||||
|
|
Loading…
Reference in a new issue