-
Notifications
You must be signed in to change notification settings - Fork 3
133 lines (114 loc) · 3.59 KB
/
test-pull-request.yml
File metadata and controls
133 lines (114 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Test Pull Request
on:
pull_request:
branches:
- main
env:
STACKS_FILEPATH: "images.json"
jobs:
preparation:
name: Preparation
runs-on: ubuntu-24.04
outputs:
stacks: ${{ steps.get-stacks.outputs.stacks }}
steps:
- name: Checkout repo
uses: actions/checkout@v6
with:
fetch-depth: 0 # gets full history
- name: Get stacks images
id: get-stacks
run: |
if [ -f ${{ env.STACKS_FILEPATH }} ]; then
stacks=$(jq -c '.images' images.json)
else
stacks=$(jq -n -c '[
{
"name": "default",
"config_dir": "stack",
"output_dir": "build",
"create_build_image": true,
}
]')
fi
stacks=$(echo "$stacks" | jq 'map({
name,
config_dir,
output_dir,
create_build_image})')
stacks=$(jq -c <<< "$stacks" )
echo "stacks=$stacks"
echo "stacks=$stacks" >> "$GITHUB_OUTPUT"
create_stack:
name: Create Stack
needs: [ preparation ]
runs-on: ubuntu-24.04
strategy:
matrix:
stacks: ${{ fromJSON(needs.preparation.outputs.stacks) }}
steps:
- name: Checkout
uses: actions/checkout@v6
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Create stack ${{ matrix.stacks.name }}
id: create-stack
run: |
scripts/create.sh --stack-dir ${{ matrix.stacks.config_dir }} \
--build-dir ${{ matrix.stacks.output_dir }}
- name: Upload run image
uses: actions/upload-artifact@v4
with:
name: current-run-image-${{ matrix.stacks.name }}
path: "${{ matrix.stacks.output_dir }}/run.oci"
if-no-files-found: error
- name: Upload build image
if: ${{ matrix.stacks.create_build_image == true }}
uses: actions/upload-artifact@v4
with:
name: current-build-image-${{ matrix.stacks.name }}
path: "${{ matrix.stacks.output_dir }}/build.oci"
if-no-files-found: error
test:
name: Acceptance Test
needs: [ preparation, create_stack ]
runs-on: ubuntu-24.04
steps:
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: stable
- name: Checkout
uses: actions/checkout@v6
- name: Download Build Image(s)
uses: actions/download-artifact@v4
with:
pattern: current-build-image-*
- name: Download Run Image(s)
uses: actions/download-artifact@v4
with:
pattern: current-run-image-*
- name: Create OCI artifacts destination directory
run: |
echo '${{ needs.preparation.outputs.stacks }}' | jq -c '.[]' | while read -r stack; do
name=$(echo "$stack" | jq -r '.name')
output_dir=$(echo "$stack" | jq -r '.output_dir')
create_build_image=$(echo "$stack" | jq -r '.create_build_image')
mkdir -p $output_dir
mv "current-run-image-${name}/run.oci" "${output_dir}/run.oci"
if [ $create_build_image == 'true' ]; then
mv "current-build-image-${name}/build.oci" "${output_dir}/build.oci"
fi
done
- name: Run Acceptance Tests
run: ./scripts/test.sh --validate-stack-builds
upload:
name: Upload Workflow Event Payload
runs-on: ubuntu-24.04
steps:
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: event-payload
path: ${{ github.event_path }}