mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-05 09:11:39 -05:00
Merge pull request #472 from nix-community/rework-gh-actions
Switch testing strategy on Github Actions to one based on a dynamic matrix
This commit is contained in:
commit
ed040fad40
2 changed files with 55 additions and 19 deletions
27
.github/generate-matrix.py
vendored
Executable file
27
.github/generate-matrix.py
vendored
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env python3
|
||||
import subprocess
|
||||
import json
|
||||
import sys
|
||||
|
||||
|
||||
expr = 'builtins.toJSON (builtins.attrNames (import ./tests {}))'
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
attrs = json.loads(json.loads(subprocess.check_output([
|
||||
"nix-instantiate",
|
||||
"--eval",
|
||||
"--expr",
|
||||
expr
|
||||
])))
|
||||
|
||||
matrix = [
|
||||
{
|
||||
"attr": attr
|
||||
}
|
||||
for attr in attrs
|
||||
]
|
||||
|
||||
sys.stdout.write("::set-output name=matrix::")
|
||||
json.dump({"include": matrix}, sys.stdout)
|
||||
sys.stdout.flush()
|
47
.github/workflows/ci.yml
vendored
47
.github/workflows/ci.yml
vendored
|
@ -2,9 +2,6 @@ name: CI
|
|||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
jobs:
|
||||
nixpkgs-fmt:
|
||||
|
@ -18,20 +15,32 @@ jobs:
|
|||
- name: Check format
|
||||
run: ./check-fmt
|
||||
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
# os: [ubuntu-latest, macos-latest]
|
||||
matrix_generate:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- uses: cachix/install-nix-action@v14
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-unstable
|
||||
extra_nix_config: experimental-features = nix-command
|
||||
- uses: actions/checkout@v2.4.0
|
||||
- uses: cachix/cachix-action@v10
|
||||
with:
|
||||
name: poetry2nix
|
||||
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
||||
- run: nix-shell -p nix-build-uncached --run 'nix-build-uncached --keep-going --show-trace tests/default.nix'
|
||||
- uses: actions/checkout@v2.4.0
|
||||
- uses: cachix/install-nix-action@v14
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-unstable
|
||||
extra_nix_config: experimental-features = nix-command
|
||||
- id: set-matrix
|
||||
run: ./.github/generate-matrix.py
|
||||
|
||||
builds:
|
||||
needs: matrix_generate
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix: ${{fromJSON(needs.matrix_generate.outputs.matrix)}}
|
||||
steps:
|
||||
- uses: actions/checkout@v2.4.0
|
||||
- uses: cachix/install-nix-action@v14
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-unstable
|
||||
extra_nix_config: experimental-features = nix-command
|
||||
- uses: cachix/cachix-action@v10
|
||||
with:
|
||||
name: poetry2nix
|
||||
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
||||
- run: nix-shell -p nix-build-uncached --run 'nix-build-uncached --keep-going --show-trace tests/default.nix -A ${{ matrix.attr }}'
|
||||
|
|
Loading…
Add table
Reference in a new issue