Build and Test the "Non-Interactive" Dockerfile #34
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
# Copyright 2024 The MathWorks, Inc. | |
name: Build and Test the "Non-Interactive" Dockerfile | |
# Trigger this workflow either manually or when a new change is pushed to the | |
# repo (except .md files) | |
on: | |
workflow_dispatch: | |
push: | |
# Trigger the workflow when the Dockerfile or any file under tests/ is modified | |
paths: | |
- "alternates/non-interactive/Dockerfile" | |
- "tests/alternates/non-interactive/*" | |
- "tests/utils/**" | |
- ".github/workflows/non-interactive-build-test.yml" | |
- "!**.md" | |
schedule: | |
# Run at 00:00 on every Monday (1st Day of the Week) | |
- cron: "0 0 * * 1" | |
env: | |
IMAGE_BASE_NAME: ghcr.io/${{ github.repository }}/matlab-non-interactive | |
ALT_PATH: alternates/non-interactive | |
jobs: | |
build-test-image: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
matlab-release: | |
- R2024b | |
- R2024a | |
- R2023b | |
- R2023a | |
- R2022b | |
- R2022a | |
- R2021b | |
- R2021a | |
- R2020b | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build image locally | |
uses: docker/build-push-action@v5 | |
with: | |
platforms: linux/amd64 | |
context: ${{ env.ALT_PATH }} | |
load: true | |
build-args: | | |
MATLAB_RELEASE=${{ matrix.matlab-release }} | |
tags: | | |
${{ env.IMAGE_BASE_NAME }}:${{ matrix.matlab-release }} | |
- name: Set up Python 3 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install test dependencies | |
run: | | |
python -m pip install --upgrade pip | |
if [ -f tests/requirements.txt ]; then pip install -r tests/requirements.txt; fi | |
- name: Test container | |
working-directory: tests | |
env: | |
IMAGE_NAME: ${{ env.IMAGE_BASE_NAME }}:${{ matrix.matlab-release }} | |
BATCH_TOKEN: ${{ secrets.MATLAB_BATCH_TOKEN_EXPIRES_03_2025 }} | |
run: python -m unittest -v ${{ env.ALT_PATH }}/*.py | |
- name: Push the image to ghcr.io | |
env: | |
MATLAB_RELEASE: ${{ matrix.matlab-release }} | |
run: | | |
LOWERCASE_RELEASE=${MATLAB_RELEASE,,} | |
UPPERCASE_RELEASE=${LOWERCASE_RELEASE^} | |
docker tag ${{ env.IMAGE_BASE_NAME }}:${MATLAB_RELEASE} ${{ env.IMAGE_BASE_NAME }}:${LOWERCASE_RELEASE} | |
docker tag ${{ env.IMAGE_BASE_NAME }}:${MATLAB_RELEASE} ${{ env.IMAGE_BASE_NAME }}:${UPPERCASE_RELEASE} | |
docker push --all-tags ${{ env.IMAGE_BASE_NAME }} |