Skip to content

Commit

Permalink
ci(github): Run functional tests in up-to-date Docker container
Browse files Browse the repository at this point in the history
Change the `build-and-test` workflow to run the functional tests in a
newly built Docker image. Before that change, functional tests were
executed in the nightly snapshot build of the ORT Docker image. This was
problematic, as changes to the Dockerfile were not immediately reflected
in the test results.

To speed of the build of the Docker image, the workflow uses the
registry cache and builts only the `all-tools` stage which does not
include the ORT build itself. The ORT installation is not required, as
the GitHub workspace is mounted into the Docker container for running
the functional tests.

Signed-off-by: Martin Nonnenmacher <[email protected]>
  • Loading branch information
mnonnenmacher committed Apr 16, 2024
1 parent cb7d27c commit 2748f23
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:

env:
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dkotest.assertions.multi-line-diff=unified
REGISTRY: ghcr.io
TEST_IMAGE_TAG: ort:test

jobs:
build:
Expand Down Expand Up @@ -116,19 +118,45 @@ jobs:
flags: funTest-non-docker
funTest-docker:
runs-on: ubuntu-22.04
container:
image: ghcr.io/oss-review-toolkit/ort:snapshot
options: --user 1001
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Run functional tests that do require external tools
- name: Free Disk Space
uses: ./.github/actions/free-disk-space
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build ORT Docker Image
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: ${{ env.TEST_IMAGE_TAG }}
target: all-tools
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/ort:cache
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-cleanup: true
arguments: --scan -Ptests.include=org.ossreviewtoolkit.plugins.packagemanagers.* funTest jacocoFunTestReport
- 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=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 }}
- name: Upload code coverage data
uses: codecov/codecov-action@v4
with:
Expand Down

0 comments on commit 2748f23

Please sign in to comment.