Skip to content

Commit ea5f2d6

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

3 files changed

Lines changed: 24 additions & 48 deletions

File tree

.github/workflows/ci.yml

Lines changed: 22 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,26 @@ jobs:
212215
name: docker-image-${{ matrix.image }}
213216
path: ./docker-image
214217
- run: ls -lasth ./docker-image/
215-
- run: docker load --input ./docker-image/image.tar
216218
- run: |
219+
cp ./docker-image/image.tags ./docker-image/image.tags-to-one-line
220+
awk '{printf("%s,",$0)} END { printf "\n" }' ./docker-image/image.tags-to-one-line
221+
printf "images=%s" $(cat ./docker-image/image.tags-to-one-line) >> $GITHUB_OUTPUT
222+
id: images
223+
- run: docker load --input ./docker-image/image.tar
224+
- run: docker image ls -a
225+
- name: Determine test suite
226+
id: test_suite
227+
run: |
217228
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=%
229+
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
219230
- run: rm -Rf ./docker-image/
231+
- uses: WyriHaximus/github-action-testinfra@main
232+
with:
233+
cmd: php
234+
image: "${{ steps.images.outputs.images }}"
235+
flags: --platform="${{ matrix.arch }}"
236+
testsPath: test
237+
testSuite: "${{ steps.test_suite.outputs.test_suite }}"
220238
check-mark:
221239
name: ✔️
222240
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)