Skip to content

Commit

Permalink
Add public tests for matlab-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
epaganon committed Oct 22, 2024
1 parent ecf438e commit f7434a1
Show file tree
Hide file tree
Showing 74 changed files with 927 additions and 259 deletions.
6 changes: 3 additions & 3 deletions .github/actions/build-test-and-publish-matlab/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ inputs:
required: true
test_dir:
required: false
default: "./tests/matlab"
default: "./tests"
license_file_path:
required: false
default: "${{ github.workspace }}/tests/licenses/license.dat"
Expand All @@ -35,7 +35,7 @@ runs:
workdir: matlab
files: |
./docker-bake.hcl
./release-config/${{ matrix.matlab_release }}.env.hcl
./release-config/${{ inputs.matlab_release }}.env.hcl
targets: ${{ inputs.variant }}
set: |
*.cache-from=type=local,src=/tmp/.buildx-cache
Expand Down Expand Up @@ -70,7 +70,7 @@ runs:
LICENSE_FILE_PATH: ${{ inputs.license_file_path }}
working-directory: ${{ inputs.test_dir }}
run: |
python -m unittest "test_${{ inputs.variant }}.py"
python -m unittest "matlab/test_${{ inputs.variant }}.py"
- name: Publish images
shell: bash
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This repository uses workflows to build the Dockerfiles hosted in this repositor
## Overview

There are 2 kinds of YML files used here:
1. `build-and-publish-docker-image.yml`, which specifies a reusable workflow, which MUST be called from a workflow configuration file.
1. `build-test-and-publish-dependencies-image.yml`, which specifies a reusable workflow, which MUST be called from a workflow configuration file.
2. Other YML files in the `.github/workflows` directory call this reusable-workflow.

Each of these workflows:
Expand Down Expand Up @@ -120,5 +120,5 @@ Each `reusable-workflow` job consists of the following steps:
1. If the variable "should_add_latest_tag" is present that an additional "latest" tag is added to the image.

----
Copyright 2023 The MathWorks, Inc.
Copyright 2023-2024 The MathWorks, Inc.
----
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
workflow_call:
inputs:
docker_build_context:
description: "Relative path to folder with Dockerfile. Ex: ./matlab-deps/r2023a/ubuntu20.04 "
description: "Relative path to folder with Dockerfile. Ex: ./matlab-deps/r2023a/ubuntu20.04"
required: true
type: string
base_image_name:
Expand All @@ -35,13 +35,24 @@ on:
description: "Specify if this image should also be tagged as latest"
required: true
type: boolean
test_file_path:
description: "Relative path to the root directory. Ex: ./tests/matlab-deps/test_ubuntu2204.py"
required: false
type: string

jobs:
build-push-image:
runs-on: ubuntu-latest
steps:
# Invalid combination would error out.
- name: Invalid combination of should_add_latest_tag set to true and is_default_os set to false
if: ${{ inputs.should_add_latest_tag == true && inputs.is_default_os == false }}
run: |
echo "Invalid situation detected. A workflow marked as latest must also set the default os to be true. "
exit 1
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Image Tags
id: setup_image_tags
Expand All @@ -55,65 +66,94 @@ jobs:
# See here for example: https://docs.docker.com/build/ci/github-actions/push-multi-registries/
- name: Login to Docker Hub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# - name: Login to GitHub Container Registry
# uses: docker/login-action@v2
# with:
# registry: ghcr.io
# username: ${{ github.repository_owner }}
# password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

# Example tags: r2023a-ubuntu20.04, R2023a-ubuntu20.04
- name: Build & Push Image
- name: Build Image
if: ${{ inputs.should_add_latest_tag == false && inputs.is_default_os == false }}
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
context: ${{ inputs.docker_build_context }}
platforms: linux/amd64
push: true
load: true
tags: |
${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_AND_OS_CAMEL_CASE }}
${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_AND_OS_PASCAL_CASE }}
# Example tags: r2023a-ubuntu20.04, R2023a-ubuntu20.04, r2023a, R2023a
- name: Build & Push Image for latest OS
- name: Build Image for latest OS
if: ${{ inputs.should_add_latest_tag == false && inputs.is_default_os == true }}
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
context: ${{ inputs.docker_build_context }}
platforms: linux/amd64
push: true
load: true
tags: |
${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_ONLY_CAMEL_CASE }}
${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_ONLY_PASCAL_CASE }}
${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_AND_OS_CAMEL_CASE }}
${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_AND_OS_PASCAL_CASE }}
# Example tags: r2023a-ubuntu20.04, R2023a-ubuntu20.04, r2023a, R2023a, latest
- name: Build & Push Image with latest Tag for latest OS
- name: Build Image with latest Tag for latest OS
if: ${{ inputs.should_add_latest_tag == true && inputs.is_default_os == true }}
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
context: ${{ inputs.docker_build_context }}
platforms: linux/amd64
push: true
load: true
tags: |
${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_ONLY_CAMEL_CASE }}
${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_ONLY_PASCAL_CASE }}
${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_AND_OS_CAMEL_CASE }}
${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_AND_OS_PASCAL_CASE }}
${{ inputs.base_image_name }}:latest
# Invalid combination would error out.
- name: Invalid combination of should_add_latest_tag set to true and is_default_os set to false
if: ${{ inputs.should_add_latest_tag == true && inputs.is_default_os == false }}
- name: Should Run Tests
id: run_tests
run: |
echo "Invalid situation detected. A workflow marked as latest must also set the default os to be true. "
exit 1
if [ -n "${{ inputs.test_file_path }}" ]; then
echo "should_run=true" >> $GITHUB_OUTPUT
else
echo "should_run=false" >> $GITHUB_OUTPUT
fi
- name: Set up Python 3
if: ${{ steps.run_tests.outputs.should_run == 'true' }}
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install test dependencies
if: ${{ steps.run_tests.outputs.should_run == 'true' }}
shell: bash
working-directory: tests
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Get test relative path
id: get_test_path
if: ${{ steps.run_tests.outputs.should_run == 'true' }}
run: |
TESTDIR=tests
echo "testdir=${TESTDIR}" >> $GITHUB_OUTPUT
echo "relpath=$(realpath --relative-to=${TESTDIR} ${{ inputs.test_file_path }})" >> $GITHUB_OUTPUT
- name: Test container
if: ${{ steps.run_tests.outputs.should_run == 'true' }}
shell: bash
env:
IMAGE_NAME: "${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_AND_OS_CAMEL_CASE }}"
working-directory: ${{ steps.get_test_path.outputs.testdir }}
run: python -m unittest -v ${{ steps.get_test_path.outputs.relpath }}

- name: Push Image
shell: bash
run: docker push --all-tags ${{ inputs.base_image_name }}
13 changes: 8 additions & 5 deletions .github/workflows/matlab-deps-r2019b-aws-batch.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright 2023 The MathWorks, Inc.
# Build & Publish matlab-deps/r2019b/aws-batch
# Copyright 2023-2024 The MathWorks, Inc.
# Build, Test & Publish matlab-deps/r2019b/aws-batch
name: matlab-deps-r2019b-aws-batch

# Define when builds will occur:
Expand All @@ -10,6 +10,8 @@ on:
- 'main'
paths:
- 'matlab-deps/r2019b/aws-batch/**'
- '/tests/matlab-deps/**'
- 'tests/pytools/**'

# Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru)
schedule:
Expand All @@ -18,13 +20,14 @@ on:
workflow_dispatch:

jobs:
build-and-publish-docker-image:
uses: ./.github/workflows/build-and-publish-docker-image.yml
build-test-and-publish-image:
uses: ./.github/workflows/build-test-and-publish-dependencies-image.yml
secrets: inherit
with:
docker_build_context: './matlab-deps/r2019b/aws-batch'
base_image_name: mathworks/matlab-deps
matlab_release_tag: 'r2019b'
os_info_tag: 'aws-batch'
is_default_os: false
should_add_latest_tag: false
should_add_latest_tag: false
test_file_path: 'tests/matlab-deps/test_awsbatch.py'
13 changes: 8 additions & 5 deletions .github/workflows/matlab-deps-r2019b-ubuntu18.04.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright 2023 The MathWorks, Inc.
# Build & Publish matlab-deps/r2019b/ubuntu18.04
# Copyright 2023-2024 The MathWorks, Inc.
# Build, Test & Publish matlab-deps/r2019b/ubuntu18.04
name: matlab-deps-r2019b-ubuntu18.04

# Define when builds will occur:
Expand All @@ -10,6 +10,8 @@ on:
- 'main'
paths:
- 'matlab-deps/r2019b/ubuntu18.04/**'
- '/tests/matlab-deps/**'
- 'tests/pytools/**'

# Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru)
schedule:
Expand All @@ -18,13 +20,14 @@ on:
workflow_dispatch:

jobs:
build-and-publish-docker-image:
uses: ./.github/workflows/build-and-publish-docker-image.yml
build-test-and-publish-image:
uses: ./.github/workflows/build-test-and-publish-dependencies-image.yml
secrets: inherit
with:
docker_build_context: './matlab-deps/r2019b/ubuntu18.04'
base_image_name: mathworks/matlab-deps
matlab_release_tag: 'r2019b'
os_info_tag: 'ubuntu18.04'
is_default_os: true
should_add_latest_tag: false
should_add_latest_tag: false
test_file_path: 'tests/matlab-deps/test_ubuntu1804.py'
13 changes: 8 additions & 5 deletions .github/workflows/matlab-deps-r2020a-aws-batch.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright 2023 The MathWorks, Inc.
# Build & Publish matlab-deps/r2020a/aws-batch
# Copyright 2023-2024 The MathWorks, Inc.
# Build, Test & Publish matlab-deps/r2020a/aws-batch
name: matlab-deps-r2020a-aws-batch

# Define when builds will occur:
Expand All @@ -10,6 +10,8 @@ on:
- 'main'
paths:
- 'matlab-deps/r2020a/aws-batch/**'
- '/tests/matlab-deps/**'
- 'tests/pytools/**'

# Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru)
schedule:
Expand All @@ -18,13 +20,14 @@ on:
workflow_dispatch:

jobs:
build-and-publish-docker-image:
uses: ./.github/workflows/build-and-publish-docker-image.yml
build-test-and-publish-image:
uses: ./.github/workflows/build-test-and-publish-dependencies-image.yml
secrets: inherit
with:
docker_build_context: './matlab-deps/r2020a/aws-batch'
base_image_name: mathworks/matlab-deps
matlab_release_tag: 'r2020a'
os_info_tag: 'aws-batch'
is_default_os: false
should_add_latest_tag: false
should_add_latest_tag: false
test_file_path: 'tests/matlab-deps/test_awsbatch.py'
13 changes: 8 additions & 5 deletions .github/workflows/matlab-deps-r2020a-ubuntu18.04.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright 2023 The MathWorks, Inc.
# Build & Publish matlab-deps/r2020a/ubuntu18.04
# Copyright 2023-2024 The MathWorks, Inc.
# Build, Test & Publish matlab-deps/r2020a/ubuntu18.04
name: matlab-deps-r2020a-ubuntu18.04

# Define when builds will occur:
Expand All @@ -10,6 +10,8 @@ on:
- 'main'
paths:
- 'matlab-deps/r2020a/ubuntu18.04/**'
- '/tests/matlab-deps/**'
- 'tests/pytools/**'

# Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru)
schedule:
Expand All @@ -18,13 +20,14 @@ on:
workflow_dispatch:

jobs:
build-and-publish-docker-image:
uses: ./.github/workflows/build-and-publish-docker-image.yml
build-test-and-publish-image:
uses: ./.github/workflows/build-test-and-publish-dependencies-image.yml
secrets: inherit
with:
docker_build_context: './matlab-deps/r2020a/ubuntu18.04'
base_image_name: mathworks/matlab-deps
matlab_release_tag: 'r2020a'
os_info_tag: 'ubuntu18.04'
is_default_os: true
should_add_latest_tag: false
should_add_latest_tag: false
test_file_path: 'tests/matlab-deps/test_ubuntu1804.py'
13 changes: 8 additions & 5 deletions .github/workflows/matlab-deps-r2020b-aws-batch.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright 2023 The MathWorks, Inc.
# Build & Publish matlab-deps/r2020b/aws-batch
# Copyright 2023-2024 The MathWorks, Inc.
# Build, Test & Publish matlab-deps/r2020b/aws-batch
name: matlab-deps-r2020b-aws-batch

# Define when builds will occur:
Expand All @@ -10,6 +10,8 @@ on:
- 'main'
paths:
- 'matlab-deps/r2020b/aws-batch/**'
- '/tests/matlab-deps/**'
- 'tests/pytools/**'

# Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru)
schedule:
Expand All @@ -18,13 +20,14 @@ on:
workflow_dispatch:

jobs:
build-and-publish-docker-image:
uses: ./.github/workflows/build-and-publish-docker-image.yml
build-test-and-publish-image:
uses: ./.github/workflows/build-test-and-publish-dependencies-image.yml
secrets: inherit
with:
docker_build_context: './matlab-deps/r2020b/aws-batch'
base_image_name: mathworks/matlab-deps
matlab_release_tag: 'r2020b'
os_info_tag: 'aws-batch'
is_default_os: false
should_add_latest_tag: false
should_add_latest_tag: false
test_file_path: 'tests/matlab-deps/test_awsbatch.py'
Loading

0 comments on commit f7434a1

Please sign in to comment.