From 082ef6f874b51ae47340fc8a3577cc904280bfb5 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Wed, 17 Apr 2024 12:27:15 +0200 Subject: [PATCH] ci(github): Revert to running funTests in a GitHub action container Signed-off-by: Sebastian Schuberth --- .github/workflows/build-and-test.yml | 49 +++++++++++++--------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 82c9f3d86c851..2020c99152a18 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -11,7 +11,6 @@ on: env: GRADLE_OPTS: -Dorg.gradle.daemon=false -Dkotest.assertions.multi-line-diff=unified REGISTRY: ghcr.io - TEST_IMAGE_TAG: ort:test jobs: build: @@ -116,13 +115,14 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} flags: funTest-non-docker - funTest-docker: + funTest-docker-build: runs-on: ubuntu-22.04 + outputs: + # Map a step output to a job output. + test_image_tag: ${{ steps.final.outputs.test_image_tag }} steps: - - name: Checkout Repository + - name: Checkout Actions uses: actions/checkout@v4 - with: - submodules: recursive - name: Free Disk Space uses: ./.github/actions/free-disk-space - name: Set up Docker Buildx @@ -131,32 +131,29 @@ jobs: uses: docker/build-push-action@v5 with: context: . - load: true - tags: ${{ env.TEST_IMAGE_TAG }} + push: true + tags: ort:${{ env.GITHUB_RUN_ID }} target: all-tools cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/ort:cache - - name: Setup Gradle + - name: Set step output + id: final + run: echo "test_image_tag=ort:${{ env.GITHUB_RUN_ID }}" >> "$GITHUB_OUTPUT" + funTest-docker: + needs: funTest-docker-build + runs-on: ubuntu-22.04 + container: + image: ${{ needs.funTest-docker-build.outputs.test_image_tag }} + options: --user 1001 + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Run functional tests that do require external tools uses: gradle/actions/setup-gradle@v3 with: gradle-home-cache-cleanup: true - - name: Run functional tests that do require external tools - run: | - # Change the ownership of the Gradle user home and the workspace to the user in the Docker container. - sudo chown -R 1000:1000 /home/runner/.gradle - sudo chown -R 1000:1000 ${{ github.workspace }} - - # Run the functional tests in the Docker container. - docker run \ - -v ${{ github.workspace }}:/workspace \ - -v /home/runner/.gradle:/home/ort/.gradle \ - -w /workspace \ - --entrypoint=/bin/sh \ - ${{ env.TEST_IMAGE_TAG }} \ - -c "GRADLE_USER_HOME=/home/ort/.gradle ./gradlew --scan -Ptests.include=org.ossreviewtoolkit.plugins.packagemanagers.* funTest jacocoFunTestReport" - - # Change the ownership of the Gradle user home and the workspace back to the user in the GitHub Actions runner. - sudo chown -R 1001:121 /home/runner/.gradle - sudo chown -R 1001:121 ${{ github.workspace }} + arguments: --scan -Ptests.include=org.ossreviewtoolkit.plugins.packagemanagers.* funTest jacocoFunTestReport - name: Upload code coverage data uses: codecov/codecov-action@v4 with: