Skip to content

Commit 41eda54

Browse files
committed
Updating github-config
1 parent ec33c62 commit 41eda54

1 file changed

Lines changed: 103 additions & 11 deletions

File tree

.github/workflows/test-pull-request.yml

Lines changed: 103 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,123 @@ on:
44
pull_request:
55
branches:
66
- main
7+
env:
8+
STACKS_FILEPATH: "images.json"
79

810
jobs:
9-
test:
10-
name: Acceptance Test
11+
preparation:
12+
name: Preparation
1113
runs-on: ubuntu-24.04
14+
outputs:
15+
stacks: ${{ steps.get-stacks.outputs.stacks }}
16+
1217
steps:
13-
- name: Checkout
14-
uses: actions/checkout@v5
18+
- name: Checkout repo
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0 # gets full history
1522

16-
- name: Setup Go
17-
uses: actions/setup-go@v6
18-
with:
19-
go-version-file: go.mod
23+
- name: Get stacks images
24+
id: get-stacks
25+
run: |
26+
27+
if [ -f ${{ env.STACKS_FILEPATH }} ]; then
28+
stacks=$(jq -c '.images' images.json)
29+
else
30+
stacks=$(jq -n -c '[
31+
{
32+
"name": "default",
33+
"config_dir": "stack",
34+
"output_dir": "build",
35+
"create_build_image": true,
36+
}
37+
]')
38+
fi
39+
40+
stacks=$(echo "$stacks" | jq 'map({
41+
name,
42+
config_dir,
43+
output_dir,
44+
create_build_image})')
45+
46+
stacks=$(jq -c <<< "$stacks" )
47+
echo "stacks=$stacks"
48+
echo "stacks=$stacks" >> "$GITHUB_OUTPUT"
49+
50+
create_stack:
51+
name: Create Stack
52+
needs: [ preparation ]
53+
runs-on: ubuntu-24.04
54+
strategy:
55+
matrix:
56+
stacks: ${{ fromJSON(needs.preparation.outputs.stacks) }}
57+
steps:
58+
- name: Checkout
59+
uses: actions/checkout@v4
2060

2161
# https://github.com/docker/setup-qemu-action
2262
- name: Set up QEMU
2363
uses: docker/setup-qemu-action@v3
2464

25-
- name: Create stack
65+
- name: Create stack ${{ matrix.stacks.name }}
2666
id: create-stack
2767
run: |
28-
./scripts/create.sh
68+
scripts/create.sh --stack-dir ${{ matrix.stacks.config_dir }} \
69+
--build-dir ${{ matrix.stacks.output_dir }}
70+
71+
- name: Upload run image
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: current-run-image-${{ matrix.stacks.name }}
75+
path: "${{ matrix.stacks.output_dir }}/run.oci"
76+
if-no-files-found: error
77+
78+
- name: Upload build image
79+
if: ${{ matrix.stacks.create_build_image == true }}
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: current-build-image-${{ matrix.stacks.name }}
83+
path: "${{ matrix.stacks.output_dir }}/build.oci"
84+
if-no-files-found: error
85+
86+
test:
87+
name: Acceptance Test
88+
needs: [ preparation, create_stack ]
89+
runs-on: ubuntu-24.04
90+
steps:
91+
- name: Setup Go
92+
uses: actions/setup-go@v5
93+
with:
94+
go-version: stable
95+
96+
- name: Checkout
97+
uses: actions/checkout@v4
98+
99+
- name: Download Build Image(s)
100+
uses: actions/download-artifact@v4
101+
with:
102+
pattern: current-build-image-*
103+
104+
- name: Download Run Image(s)
105+
uses: actions/download-artifact@v4
106+
with:
107+
pattern: current-run-image-*
108+
109+
- name: Create OCI artifacts destination directory
110+
run: |
111+
echo '${{ needs.preparation.outputs.stacks }}' | jq -c '.[]' | while read -r stack; do
112+
name=$(echo "$stack" | jq -r '.name')
113+
output_dir=$(echo "$stack" | jq -r '.output_dir')
114+
create_build_image=$(echo "$stack" | jq -r '.create_build_image')
115+
mkdir -p $output_dir
116+
mv "current-run-image-${name}/run.oci" "${output_dir}/run.oci"
117+
if [ $create_build_image == 'true' ]; then
118+
mv "current-build-image-${name}/build.oci" "${output_dir}/build.oci"
119+
fi
120+
done
29121
30122
- name: Run Acceptance Tests
31-
run: ./scripts/test.sh
123+
run: ./scripts/test.sh --validate-stack-builds
32124

33125
upload:
34126
name: Upload Workflow Event Payload

0 commit comments

Comments
 (0)