Skip to content

Commit e592639

Browse files
committed
Dynamic matrix
1 parent df26695 commit e592639

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

.github/workflows/ci.yml

+13-16
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,27 @@ concurrency:
77
cancel-in-progress: true
88

99
jobs:
10+
pre-build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: cachix/install-nix-action@v22
15+
- run: echo "package=$(./foo)" >> "$GITHUB_OUTPUT"
16+
id: foo
17+
outputs:
18+
package: ${{ steps.foo.ouputs.package }}
19+
1020
build:
1121
strategy:
12-
# TODO: Create a dynamic matrix
1322
matrix:
1423
runner:
1524
- os: macos-latest
1625
system: x86_64-darwin
1726
- os: ubuntu-latest
1827
system: x86_64-linux
19-
package:
20-
- name: terraform-1_6_3
21-
version: 1.6.3
22-
allow_unfree: 1
23-
# - name: terraform-1_6_1
24-
# version: 1.6.1
25-
# allow_unfree: 1
26-
# - name: terraform-1_6_0
27-
# version: 1.6.0
28-
# allow_unfree: 1
29-
# - name: terraform-1_5_7
30-
# version: 1.5.7
31-
# allow_unfree: 0
32-
#
28+
package: ${{ needs.pre-build.outputs.package }}
3329
runs-on: ${{ matrix.runner.os }}
30+
needs: [pre-build]
3431
steps:
3532
- uses: actions/checkout@v4
3633
- uses: cachix/install-nix-action@v22
@@ -42,4 +39,4 @@ jobs:
4239
id: nix-build
4340
env:
4441
NIXPKGS_ALLOW_UNFREE: ${{ matrix.package.allow_unfree }}
45-
- run: cachix pin nixpkgs-terraform v${{ matrix.package.version }}-${{ matrix.runner.system }} ${{ steps.nix-build.outputs.out-paths }} --keep-revisions 1
42+
# - run: cachix pin nixpkgs-terraform v${{ matrix.package.version }}-${{ matrix.runner.system }} ${{ steps.nix-build.outputs.out-paths }} --keep-revisions 1

foo

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env nix-shell
2+
#!nix-shell -i python3 -p python3Packages.semver
3+
4+
# vi: ft=python
5+
6+
import json
7+
import semver
8+
9+
def foo(version):
10+
splitted_version = version.split(".")
11+
package_suffix = "_".join(splitted_version)
12+
return { "version": version, "package": f"terraform-{package_suffix}", "allow_unfree": 1 if semver.compare(version, "1.6.0") >= 0 else 0 }
13+
14+
with open("versions.json") as f:
15+
versions = json.load(f)
16+
result = list(map(foo, versions))
17+
print(json.dumps(result))

0 commit comments

Comments
 (0)