diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0eb22c38..383f43c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,8 @@ jobs: - id: supported-arch-matrix name: Generate Arch run: | - echo "arch=[\\\"amd64\\\",\\\"arm64\\\"]" >> $GITHUB_OUTPUT + echo "arch=[\\\"amd64\\\"]" >> $GITHUB_OUTPUT +# echo "arch=[\\\"amd64\\\",\\\"arm64\\\"]" >> $GITHUB_OUTPUT image-type-matrix: name: Create Image Type Matrix runs-on: ubuntu-22.04 @@ -191,7 +192,7 @@ jobs: - run: make ci-scan-vulnerability if: contains(matrix.image, 'alpine') test: - name: Testing "${{ matrix.image }}" + name: Testing "${{ matrix.image }}" on "${{ matrix.arch }}" needs: - build - image-matrix @@ -201,6 +202,8 @@ jobs: strategy: fail-fast: false matrix: + arch: + - linux/amd64 image: ${{ fromJson(needs.image-matrix.outputs.image) }} exclude: ${{ fromJson(needs.exclude-matrix.outputs.exclude) }} steps: @@ -212,11 +215,23 @@ jobs: name: docker-image-${{ matrix.image }} path: ./docker-image - run: ls -lasth ./docker-image/ + - run: printf "images=%s" $(awk '{printf("%s,",$0)} END { printf "\n" }' ./docker-image/image.tags) >> $GITHUB_OUTPUT + id: images - run: docker load --input ./docker-image/image.tar - - run: | + - run: docker image ls -a + - name: Determine test suite + id: test_suite + run: | export IMAGE_BASE_VERSION=$(php -r 'echo explode("-", "${{ matrix.image }}")[2];') - (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=% + 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 - run: rm -Rf ./docker-image/ + - uses: WyriHaximus/github-action-testinfra@main + with: + cmd: php + image: "${{ steps.images.outputs.images }}" + flags: --platform="${{ matrix.arch }}" + testsPath: test + testSuite: "${{ steps.test_suite.outputs.test_suite }}" check-mark: name: ✔️ needs: diff --git a/test-nts.sh b/test-nts.sh index d2a31b75..62e47b9d 100755 --- a/test-nts.sh +++ b/test-nts.sh @@ -37,25 +37,4 @@ else TEST_SUITE="php_app or $TEST_SUITE" fi -printf "Starting a container for '%s'\\n" "$DOCKER_TAG" - -DOCKER_CONTAINER=$(docker run --rm -v "$(pwd)/test:/tests" -t -d "$DOCKER_TAG" php) -readonly DOCKER_CONTAINER - -# Let's register a trap function, if our tests fail, finish or the script gets -# interrupted, we'll still be able to remove the running container -function tearDown { - docker rm -f "$DOCKER_CONTAINER" &>/dev/null & -} -trap tearDown EXIT TERM ERR - -# Finally, run the tests! -echo "Running test suite: $TEST_SUITE" -docker run --rm -t \ - -v "$(pwd)/test:/tests" \ - -v "$(pwd)/tmp/test-results:/results" \ - -v /var/run/docker.sock:/var/run/docker.sock:ro \ - renatomefi/docker-testinfra:5 \ - -m "$TEST_SUITE" --junitxml="/results/php-nts-$DOCKER_TAG.xml" \ - --disable-pytest-warnings \ - --verbose --hosts="docker://$DOCKER_CONTAINER" \ No newline at end of file +echo $TEST_SUITE diff --git a/test-zts.sh b/test-zts.sh index 8f7650b7..f55b1573 100755 --- a/test-zts.sh +++ b/test-zts.sh @@ -37,25 +37,4 @@ else TEST_SUITE="php_app or $TEST_SUITE" fi -printf "Starting a container for '%s'\\n" "$DOCKER_TAG" - -DOCKER_CONTAINER=$(docker run --rm -v "$(pwd)/test:/tests" -t -d "$DOCKER_TAG" php) -readonly DOCKER_CONTAINER - -# Let's register a trap function, if our tests fail, finish or the script gets -# interrupted, we'll still be able to remove the running container -function tearDown { - docker rm -f "$DOCKER_CONTAINER" &>/dev/null & -} -trap tearDown EXIT TERM ERR - -# Finally, run the tests! -echo "Running test suite: $TEST_SUITE" -docker run --rm -t \ - -v "$(pwd)/test:/tests" \ - -v "$(pwd)/tmp/test-results:/results" \ - -v /var/run/docker.sock:/var/run/docker.sock:ro \ - renatomefi/docker-testinfra:5 \ - -m "$TEST_SUITE" --junitxml="/results/php-zts-$DOCKER_TAG.xml" \ - --disable-pytest-warnings \ - --verbose --hosts="docker://$DOCKER_CONTAINER" \ No newline at end of file +echo $TEST_SUITE