Skip to content

Commit 686dc0c

Browse files
committed
Use action for image testing
1 parent 345e0fc commit 686dc0c

File tree

3 files changed

+21
-48
lines changed

3 files changed

+21
-48
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ jobs:
3939
- id: supported-arch-matrix
4040
name: Generate Arch
4141
run: |
42-
echo "arch=[\\\"amd64\\\",\\\"arm64\\\"]" >> $GITHUB_OUTPUT
42+
echo "arch=[\\\"amd64\\\"]" >> $GITHUB_OUTPUT
43+
# echo "arch=[\\\"amd64\\\",\\\"arm64\\\"]" >> $GITHUB_OUTPUT
4344
image-type-matrix:
4445
name: Create Image Type Matrix
4546
runs-on: ubuntu-22.04
@@ -191,7 +192,7 @@ jobs:
191192
- run: make ci-scan-vulnerability
192193
if: contains(matrix.image, 'alpine')
193194
test:
194-
name: Testing "${{ matrix.image }}"
195+
name: Testing "${{ matrix.image }}" on "${{ matrix.arch }}"
195196
needs:
196197
- build
197198
- image-matrix
@@ -201,6 +202,8 @@ jobs:
201202
strategy:
202203
fail-fast: false
203204
matrix:
205+
arch:
206+
- linux/amd64
204207
image: ${{ fromJson(needs.image-matrix.outputs.image) }}
205208
exclude: ${{ fromJson(needs.exclude-matrix.outputs.exclude) }}
206209
steps:
@@ -212,11 +215,23 @@ jobs:
212215
name: docker-image-${{ matrix.image }}
213216
path: ./docker-image
214217
- run: ls -lasth ./docker-image/
218+
- run: printf "images=%s" $(awk '{printf("%s,",$0)} END { printf "\n" }' ./docker-image/image.tags) >> $GITHUB_OUTPUT
219+
id: images
215220
- run: docker load --input ./docker-image/image.tar
216-
- run: |
221+
- run: docker image ls -a
222+
- name: Determine test suite
223+
id: test_suite
224+
run: |
217225
export IMAGE_BASE_VERSION=$(php -r 'echo explode("-", "${{ matrix.image }}")[2];')
218-
(echo "${{ needs.supported-arch-matrix.outputs.arch }}" | jq -r '.[]') | xargs -I % make $(php -r 'echo "test-", explode("-", str_replace(["zts-zts", "cli-nts"], ["zts", "nts"], "${{ matrix.image }}"))[0];') IMAGE_ARCH=%
226+
printf "test_suite=%s" $(make $(php -r 'echo "test-", explode("-", str_replace(["zts-zts", "cli-nts"], ["zts", "nts"], "${{ matrix.image }}"))[0];') IMAGE_ARCH=${{ matrix.arch }}) >> $GITHUB_OUTPUT
219227
- run: rm -Rf ./docker-image/
228+
- uses: WyriHaximus/github-action-testinfra@main
229+
with:
230+
cmd: php
231+
image: "${{ steps.images.outputs.images }}"
232+
flags: --platform="${{ matrix.arch }}"
233+
testsPath: test
234+
testSuite: "${{ steps.test_suite.outputs.test_suite }}"
220235
check-mark:
221236
name: ✔️
222237
needs:

test-nts.sh

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,4 @@ else
3737
TEST_SUITE="php_app or $TEST_SUITE"
3838
fi
3939

40-
printf "Starting a container for '%s'\\n" "$DOCKER_TAG"
41-
42-
DOCKER_CONTAINER=$(docker run --rm -v "$(pwd)/test:/tests" -t -d "$DOCKER_TAG" php)
43-
readonly DOCKER_CONTAINER
44-
45-
# Let's register a trap function, if our tests fail, finish or the script gets
46-
# interrupted, we'll still be able to remove the running container
47-
function tearDown {
48-
docker rm -f "$DOCKER_CONTAINER" &>/dev/null &
49-
}
50-
trap tearDown EXIT TERM ERR
51-
52-
# Finally, run the tests!
53-
echo "Running test suite: $TEST_SUITE"
54-
docker run --rm -t \
55-
-v "$(pwd)/test:/tests" \
56-
-v "$(pwd)/tmp/test-results:/results" \
57-
-v /var/run/docker.sock:/var/run/docker.sock:ro \
58-
renatomefi/docker-testinfra:5 \
59-
-m "$TEST_SUITE" --junitxml="/results/php-nts-$DOCKER_TAG.xml" \
60-
--disable-pytest-warnings \
61-
--verbose --hosts="docker://$DOCKER_CONTAINER"
40+
echo $TEST_SUITE

test-zts.sh

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,4 @@ else
3737
TEST_SUITE="php_app or $TEST_SUITE"
3838
fi
3939

40-
printf "Starting a container for '%s'\\n" "$DOCKER_TAG"
41-
42-
DOCKER_CONTAINER=$(docker run --rm -v "$(pwd)/test:/tests" -t -d "$DOCKER_TAG" php)
43-
readonly DOCKER_CONTAINER
44-
45-
# Let's register a trap function, if our tests fail, finish or the script gets
46-
# interrupted, we'll still be able to remove the running container
47-
function tearDown {
48-
docker rm -f "$DOCKER_CONTAINER" &>/dev/null &
49-
}
50-
trap tearDown EXIT TERM ERR
51-
52-
# Finally, run the tests!
53-
echo "Running test suite: $TEST_SUITE"
54-
docker run --rm -t \
55-
-v "$(pwd)/test:/tests" \
56-
-v "$(pwd)/tmp/test-results:/results" \
57-
-v /var/run/docker.sock:/var/run/docker.sock:ro \
58-
renatomefi/docker-testinfra:5 \
59-
-m "$TEST_SUITE" --junitxml="/results/php-zts-$DOCKER_TAG.xml" \
60-
--disable-pytest-warnings \
61-
--verbose --hosts="docker://$DOCKER_CONTAINER"
40+
echo $TEST_SUITE

0 commit comments

Comments
 (0)