-
Notifications
You must be signed in to change notification settings - Fork 1
159 lines (144 loc) · 5.14 KB
/
Copy pathdocker-pipeline.yml
File metadata and controls
159 lines (144 loc) · 5.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Copyright 2026 The MathWorks, Inc.
name: Docker Pipeline
on:
workflow_call:
inputs:
image_type:
description: "Type of image to build"
type: string
required: true
matlab_release:
description: "MATLAB Release (e.g., R2026a)"
type: string
required: true
databricks_runtime:
description: "Databricks Runtime Version (e.g., 17.3)"
type: string
required: true
matlab_update:
description: "MATLAB Update (e.g., U4). Empty = latest update for MATLAB, base release for Runtime."
type: string
required: false
default: ''
run_integration:
description: "Run integration tests after docker tests"
type: boolean
required: false
default: false
promote:
description: "Push production-tagged image to GHCR after all tests pass"
type: boolean
required: false
default: false
secrets:
MATLAB_LICENSE_FILE:
required: false
env:
REGISTRY: ghcr.io
REPO_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Free up disk space
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: Configure build environment
shell: bash
run: |
DBR_MAJOR=$(echo "${{ inputs.databricks_runtime }}" | cut -d. -f1)
if [ "$DBR_MAJOR" -ge 16 ]; then
UBUNTU_VERSION="24.04"
else
UBUNTU_VERSION="22.04"
fi
# Convert unified matlab_update (U<number>) to Dockerfile-specific format
if [ "${{ inputs.image_type }}" = "runtime" ]; then
if [ -n "${{ inputs.matlab_update }}" ]; then
# Strip 'U' prefix for runtime Dockerfile (expects numeric)
MATLAB_UPDATE=$(echo "${{ inputs.matlab_update }}" | sed 's/^[Uu]//')
else
MATLAB_UPDATE=0
fi
else
MATLAB_UPDATE="${{ inputs.matlab_update }}"
fi
{
echo "IMAGE_TAG=${{ inputs.image_type }}:local"
echo "BUILD_CONTEXT=resources/dockerfiles/${{ inputs.image_type }}"
echo "DATABRICKS_RUNTIME_VERSION=${{ inputs.databricks_runtime }}"
echo "UBUNTU_VERSION=${UBUNTU_VERSION}"
echo "MATLAB_UPDATE=${MATLAB_UPDATE}"
} >> "$GITHUB_ENV"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and load image
uses: docker/build-push-action@v7
with:
context: "{{defaultContext}}:${{ env.BUILD_CONTEXT }}"
build-args: |
MATLAB_RELEASE=${{ inputs.matlab_release }}
MATLAB_UPDATE=${{ env.MATLAB_UPDATE }}
DATABRICKS_RUNTIME_VERSION=${{ env.DATABRICKS_RUNTIME_VERSION }}
UBUNTU_VERSION=${{ env.UBUNTU_VERSION }}
tags: ${{ env.IMAGE_TAG }}
load: true
push: false
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install test dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r tests/docker/requirements.txt
- name: Run docker tests
run: python3 -m pytest tests/docker/${{ inputs.image_type }}
env:
IMAGE_NAME: ${{ env.IMAGE_TAG }}
MATLAB_RELEASE: ${{ inputs.matlab_release }}
MATLAB_UPDATE: ${{ inputs.matlab_update }}
DB_RUNTIME: ${{ inputs.databricks_runtime }}
MATLAB_LICENSE_FILE: ${{ secrets.MATLAB_LICENSE_FILE }}
- name: Run integration tests
if: ${{ inputs.run_integration }}
run: python3 -m pytest tests/docker/integration
env:
IMAGE_NAME: ${{ env.IMAGE_TAG }}
MATLAB_RELEASE: ${{ inputs.matlab_release }}
MATLAB_UPDATE: ${{ inputs.matlab_update }}
DB_RUNTIME: ${{ inputs.databricks_runtime }}
MATLAB_LICENSE_FILE: ${{ secrets.MATLAB_LICENSE_FILE }}
- name: Promote image
if: ${{ success() && inputs.promote }}
env:
IMAGE_TAG: ${{ env.IMAGE_TAG }}
PROD_TAG: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}/${{ inputs.image_type }}:${{ inputs.matlab_release }}-${{ inputs.databricks_runtime }}
run: |
docker tag "$IMAGE_TAG" "$PROD_TAG"
docker push "$PROD_TAG"