From 3e5fe855dc19f09d26ad272f2d5b7138c6f94aef 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 | 55 +++++++++++++++------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 82c9f3d86c851..9e22dafd91dab 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,47 +115,51 @@ 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 uses: docker/setup-buildx-action@v3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build ORT Docker Image uses: docker/build-push-action@v5 with: context: . - load: true - tags: ${{ env.TEST_IMAGE_TAG }} + push: true + tags: ort:run-${{ 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:run-${{ 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: