Skip to content

Commit 7a6f599

Browse files
committed
feat: matrix on Test Database
1 parent e67dbfe commit 7a6f599

File tree

2 files changed

+40
-5
lines changed

2 files changed

+40
-5
lines changed

.github/workflows/test.yml

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,27 @@ on:
88
workflow_dispatch:
99

1010
jobs:
11+
prepare:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
postgres_versions: ${{ steps.set-versions.outputs.postgres_versions }}
15+
steps:
16+
- name: Checkout Repo
17+
uses: actions/checkout@v4
18+
19+
- uses: DeterminateSystems/nix-installer-action@main
20+
21+
- name: Set PostgreSQL versions
22+
id: set-versions
23+
run: |
24+
VERSIONS=$(nix run nixpkgs#yq -- '.postgres_major[]' ansible/vars.yml | nix run nixpkgs#jq -- -R -s -c 'split("\n")[:-1]')
25+
echo "postgres_versions=$VERSIONS" >> $GITHUB_OUTPUT
26+
1127
build:
28+
needs: prepare
1229
strategy:
1330
matrix:
31+
postgres_version: ${{ fromJson(needs.prepare.outputs.postgres_versions) }}
1432
include:
1533
- runner: [self-hosted, X64]
1634
arch: amd64
@@ -23,14 +41,31 @@ jobs:
2341
POSTGRES_PASSWORD: password
2442
steps:
2543
- uses: actions/checkout@v3
44+
45+
- uses: DeterminateSystems/nix-installer-action@main
46+
47+
- name: Set PostgreSQL version environment variable
48+
run: echo "POSTGRES_MAJOR_VERSION=${{ matrix.postgres_version }}" >> $GITHUB_ENV
49+
50+
- name: Generate common-nix.vars.pkr.hcl
51+
run: |
52+
PG_VERSION=$(nix run nixpkgs#yq -- '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
53+
PG_VERSION=$(echo $PG_VERSION | tr -d '"') # Remove any surrounding quotes
54+
echo 'postgres-version = "'$PG_VERSION'"' > common-nix.vars.pkr.hcl
55+
# Ensure there's a newline at the end of the file
56+
echo "" >> common-nix.vars.pkr.hcl
57+
2658
- id: settings
2759
# Remove spaces and quotes to get the raw version string
2860
run: sed -r 's/(\s|\")+//g' common-nix.vars.pkr.hcl >> $GITHUB_OUTPUT
2961

30-
- id: args
31-
uses: mikefarah/yq@master
32-
with:
33-
cmd: yq 'to_entries | map(select(.value|type == "!!str")) | map(.key + "=" + .value) | join("\n")' 'ansible/vars.yml'
62+
- name: Generate args
63+
id: args
64+
run: |
65+
ARGS=$(nix run nixpkgs#yq -- 'to_entries | map(select(.value|type == "!!str")) | map(.key + "=" + .value) | join("\n")' ansible/vars.yml)
66+
echo "result<<EOF" >> $GITHUB_OUTPUT
67+
echo "$ARGS" >> $GITHUB_OUTPUT
68+
echo "EOF" >> $GITHUB_OUTPUT
3469
3570
- run: docker context create builders
3671
- uses: docker/setup-buildx-action@v3

.github/workflows/testinfra-nix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,4 @@ jobs:
120120
121121
# Deregister AMIs
122122
deregister_ami_by_name "$STAGE1_AMI_NAME"
123-
deregister_ami_by_name "$STAGE2_AMI_NAME"
123+
deregister_ami_by_name "$STAGE2_AMI_NAME"

0 commit comments

Comments
 (0)