-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Publish the Dockerfiles and GitHub Actions for building and testing t…
…he mathworks/matlab and mathworks/matlab-deep-learning Docker images on Docker Hub.
- Loading branch information
1 parent
4d01324
commit ae93bbd
Showing
72 changed files
with
3,603 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Copyright 2024 The MathWorks, Inc. | ||
|
||
# This file tests & publishes the Docker Images to DockerHub. | ||
|
||
name: Test and Publish MATLAB Image | ||
|
||
inputs: | ||
variant: | ||
required: true | ||
matlab_release: | ||
required: true | ||
matlab_license_file: | ||
required: true | ||
base_image_name: | ||
required: true | ||
test_dir: | ||
required: false | ||
default: "./tests/matlab" | ||
license_file_path: | ||
required: false | ||
default: "${{ github.workspace }}/tests/licenses/license.dat" | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build image | ||
uses: docker/bake-action@v5 | ||
with: | ||
workdir: matlab | ||
files: | | ||
./docker-bake.hcl | ||
./release-config/${{ matrix.matlab_release }}.env.hcl | ||
targets: ${{ inputs.variant }} | ||
set: | | ||
*.cache-from=type=local,src=/tmp/.buildx-cache | ||
*.cache-to=type=local,mode=max,dest=/tmp/.buildx-cache | ||
load: true | ||
|
||
- name: Set up Python 3 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Install test dependencies | ||
shell: bash | ||
working-directory: ${{ inputs.test_dir }} | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Generate license file | ||
shell: bash | ||
working-directory: tests/tools | ||
env: | ||
LICENSE_FILE_PATH: ${{ inputs.license_file_path }} | ||
MATLAB_LICENSE_FILE: ${{ inputs.matlab_license_file }} | ||
run: | | ||
./gen_license_file.sh | ||
- name: Test container | ||
shell: bash | ||
env: | ||
IMAGE_NAME: "${{ inputs.base_image_name }}:${{ inputs.matlab_release }}" | ||
LICENSE_FILE_PATH: ${{ inputs.license_file_path }} | ||
working-directory: ${{ inputs.test_dir }} | ||
run: | | ||
python -m unittest "test_${{ inputs.variant }}.py" | ||
- name: Publish images | ||
shell: bash | ||
run: | | ||
docker push --all-tags ${{ inputs.base_image_name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# Copyright 2024 The MathWorks, Inc. | ||
|
||
# This file builds, tests & publishes the mathworks/matlab and mathworks/matlab-deep-learning Docker Images to DockerHub. | ||
# Both images are built during a single job to optimise caching and final storage size for the images. | ||
|
||
name: Build, Test and Publish MATLAB images | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
# Runs at 02:00 every Monday | ||
schedule: | ||
- cron: "0 2 * * 1" | ||
|
||
push: | ||
branches: ["main"] | ||
paths: | ||
- ".github/workflows/build-test-and-publish-matlab.yml" | ||
- ".github/actions/build-test-and-publish-matlab/action.yml" | ||
- "matlab/*" | ||
- "tests/matlab/*" | ||
- "!matlab/*.md" | ||
|
||
jobs: | ||
test-shell-scripts: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run shell script unit tests | ||
working-directory: tests/matlab | ||
run: ./run-bats-test.sh | ||
|
||
build-test-push-matlab: | ||
needs: test-shell-scripts | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
matlab_release: [R2024a, R2023b, R2023a] | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
# GitHub runners come preinstalled with a lot of software that | ||
# is not needed for this workflow. To increase available space | ||
# these packages are removed. | ||
# https://github.com/actions/runner-images/issues/2840 | ||
- name: Cleanup | ||
run: | | ||
sudo rm -rf \ | ||
"$AGENT_TOOLSDIRECTORY" \ | ||
/opt/google/chrome \ | ||
/opt/microsoft/msedge \ | ||
/opt/microsoft/powershell \ | ||
/opt/pipx \ | ||
/usr/lib/mono \ | ||
/usr/local/julia* \ | ||
/usr/local/lib/android \ | ||
/usr/local/lib/node_modules \ | ||
/usr/local/share/chromium \ | ||
/usr/local/share/powershell \ | ||
/usr/share/dotnet \ | ||
/usr/share/swift | ||
df -h / | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build, Test, and Publish MATLAB | ||
id: build-test-and-publish-matlab-to-dockerhub | ||
uses: ./.github/actions/build-test-and-publish-matlab | ||
with: | ||
variant: matlab | ||
matlab_release: ${{ matrix.matlab_release }} | ||
matlab_license_file: ${{ secrets.MATLAB_LICENSE_FILE_R2024A }} | ||
base_image_name: "mathworks/matlab" | ||
|
||
- name: Build, Test, and Publish MATLAB Deep Learning | ||
# Run this step even if the previous step failed | ||
if: success() || steps.build-test-and-publish-matlab-to-dockerhub.outcome == 'failure' | ||
uses: ./.github/actions/build-test-and-publish-matlab | ||
with: | ||
variant: matlab-deep-learning | ||
matlab_release: ${{ matrix.matlab_release }} | ||
matlab_license_file: ${{ secrets.MATLAB_LICENSE_FILE_R2024A }} | ||
base_image_name: "mathworks/matlab-deep-learning" | ||
|
||
- name: Fail job if any tests failed | ||
if: steps.build-test-and-publish-matlab-to-dockerhub.outcome == 'failure' | ||
run: exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
__pycache__ | ||
**/*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.