Skip to content

Commit e352b64

Browse files
authored
Fix workflow bugs (#61)
* Update release.yml - Add R2021b and R2022a to test matrix - Support workflow dispatch event - Skip code coverage upload * Add job to abort if the tag commit is a retag * Support two event modes for triggering the release workflow * Add fallback for function not existing until R2023b * Update MetaTypeRegistry.m * Update TutorialTest.m - Use relative path name as the test parameter. * Update Collection.m Fix retrieval of instance keys for R2022b and R2023a * Update release.yml Add conditional tag deletion * Update release.yml * Update release.yml * Update updateCodeMetaFile.m Ensure author is an array in the final json * Update MLToolboxInfo.json * Update updateCodeMetaFile.m * Update README.md * Fix/suppress code issues * Fix suppressed code issues * Update run_tests.yml * Update code issues and tests badges * Add email adress to workflow commits * Update workflow files Replace , with ; for command separation in MATLAB commands Move steps for better logical step sequence Fetch tags before potentially retagging to make sure tags are present locally Add skip-ci tag to commit message in release workflow * Update release.yml Change step name to avoid using the same name as in the first job --------- Co-authored-by: Run tests by ehennestad <>
1 parent 2781dfb commit e352b64

File tree

4 files changed

+52
-40
lines changed

4 files changed

+52
-40
lines changed

.github/badges/code_issues.svg

Lines changed: 1 addition & 1 deletion
Loading

.github/badges/tests.svg

Lines changed: 1 addition & 1 deletion
Loading

.github/workflows/release.yml

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
with:
8888
command: |
8989
addpath(genpath("tools"));
90-
testToolbox('ReportSubdirectory',"${{ matrix.MATLABVersion }}", 'CreateBadge', false)
90+
testToolbox('ReportSubdirectory', "${{ matrix.MATLABVersion }}", 'CreateBadge', false)
9191
9292
# Save the contents of the report directory from each release into an artifact.
9393
- name: Save report directory
@@ -129,7 +129,36 @@ jobs:
129129
- name: Generate tested with badge
130130
uses: matlab-actions/run-command@v2
131131
with:
132-
command: addpath(genpath("tools")), createTestedWithBadgeforToolbox("${{ env.VERSION_TAG }}")
132+
command: |
133+
addpath(genpath("tools"));
134+
createTestedWithBadgeforToolbox("${{ env.VERSION_TAG }}")
135+
136+
# Check out the gh-badges in a separate folder to commit the JSON badge
137+
- name: Checkout gh-badges branch
138+
uses: actions/checkout@v4
139+
with:
140+
ref: gh-badges
141+
path: gh-badges
142+
token: ${{ secrets.GITHUB_TOKEN }}
143+
144+
# Push the JSON badge to the gh-badges (if changes were detected)
145+
- name: Push to gh-badges
146+
run: |
147+
mkdir -p gh-badges/.github/badges/${{ env.VERSION_TAG }}
148+
cp .github/badges/${{ env.VERSION_TAG }}/tested_with.json gh-badges/.github/badges/${{ env.VERSION_TAG }}/tested_with.json
149+
cd gh-badges
150+
151+
git config user.name "${{ github.workflow }} by ${{ github.actor }}"
152+
git config user.email "${{ secrets.COMMIT_EMAIL_ADDRESS }}"
153+
154+
# Only proceed with commit and push if changes are detected
155+
if [[ $(git add .github/badges/* --dry-run | wc -l) -gt 0 ]]; then
156+
git add .github/badges/*
157+
git commit -m "Update tested with badge for release"
158+
git push -f
159+
else
160+
echo "Nothing to commit"
161+
fi
133162
134163
# Publish test results from all the releases
135164
- name: Publish test results
@@ -142,11 +171,13 @@ jobs:
142171
- name: Package toolbox
143172
uses: matlab-actions/run-command@v2
144173
with:
145-
command: addpath(genpath("tools")), packageToolbox("specific","${{ env.VERSION_TAG }}")
174+
command: |
175+
addpath(genpath("tools"));
176+
packageToolbox("specific", "${{ env.VERSION_TAG }}")
146177
147178
# Define the versionNumber using underscores, as this is used in the MLTBX
148-
- name: Set version number
149-
id: set_version
179+
- name: Format version tag with underscores and add to environment
180+
id: set_version_with_underscores
150181
run: |
151182
versionNumber=$(echo "${{ env.VERSION_TAG }}" | sed 's/\./_/g')
152183
echo "versionNumber=$versionNumber" >> $GITHUB_ENV
@@ -165,52 +196,29 @@ jobs:
165196
addpath(genpath("tools"));
166197
updateCodeMetaFile("${{ env.VERSION_TAG }}")
167198
168-
# Commit the updated Contents.m
169-
- name: Commit updated Contents.m file
199+
# Commit the updated Contents.m and codemeta.json
200+
- name: Commit updated Contents.m and codemeta.json files
170201
continue-on-error: true
171202
run: |
172203
git config user.name "${{ github.workflow }} by ${{ github.actor }}"
173-
git config user.email "<>"
204+
git config user.email "${{ secrets.COMMIT_EMAIL_ADDRESS }}"
174205
git status
175206
git add code/Contents.m
176207
git add codemeta.json
177-
git commit -m "Final checkins for release ${{ env.VERSION_TAG }}"
208+
git commit -m "Final check-ins for release ${{ env.VERSION_TAG }} [skip-ci]"
178209
git fetch
179210
git push
180211
181-
# Commit the JSON for the MATLAB releases test badge to gh-badges branch
182-
- name: Checkout gh-badges branch
183-
uses: actions/checkout@v4
184-
with:
185-
ref: gh-badges
186-
path: gh-badges
187-
token: ${{ secrets.GITHUB_TOKEN }}
188-
189-
- name: Push to gh-badges
190-
run: |
191-
mkdir -p gh-badges/.github/badges/${{ env.VERSION_TAG }}
192-
cp .github/badges/${{ env.VERSION_TAG }}/tested_with.json gh-badges/.github/badges/${{ env.VERSION_TAG }}/tested_with.json
193-
cd gh-badges
194-
195-
git config user.name "${{ github.workflow }} by ${{ github.actor }}"
196-
git config user.email "<>"
197-
198-
# Only proceed with commit and push if changes are detected
199-
if [[ $(git add .github/badges/* --dry-run | wc -l) -gt 0 ]]; then
200-
git add .github/badges/*
201-
git commit -m "Update tested with badge for release"
202-
git push -f
203-
else
204-
echo "Nothing to commit"
205-
fi
212+
- name: Fetch tags
213+
run: git fetch --tags
206214

207215
# (Re)tag the repo so that the updated files are included in the release tag
208216
- name: Update tag
209217
if: always()
210218
continue-on-error: true
211219
run: |
212220
git config user.name "${{ github.workflow }} by ${{ github.actor }}"
213-
git config user.email "<>"
221+
git config user.email "${{ secrets.COMMIT_EMAIL_ADDRESS }}"
214222
215223
# Delete the existing tag locally and remotely if it already exists
216224
if git rev-parse --verify "refs/tags/${{ env.VERSION_TAG }}" > /dev/null 2>&1; then

.github/workflows/run_tests.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
paths-ignore:
1010
- '*.md'
1111
- '.github/**'
12+
- '**/Contents.m'
13+
- '**/codemeta.json'
1214
pull_request:
1315
branches: [ "main" ]
1416
# Allows for manually running this workflow from the Actions tab
@@ -31,6 +33,8 @@ jobs:
3133
# Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it
3234
- name: Check out repo
3335
uses: actions/checkout@v4
36+
with:
37+
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}
3438

3539
- name: Set up MATLAB
3640
uses: matlab-actions/setup-matlab@v2
@@ -42,7 +46,7 @@ jobs:
4246
if: matrix.MATLABVersion == env.LatestMATLABVersion
4347
uses: matlab-actions/run-command@v2
4448
with:
45-
command: addpath(genpath("tools")),codecheckToolbox()
49+
command: addpath(genpath("tools")); codecheckToolbox()
4650

4751
# Upload code issues report
4852
- name: Upload SARIF file
@@ -61,15 +65,15 @@ jobs:
6165
with:
6266
command: |
6367
doCreateBadge = "${{ matrix.MATLABVersion }}" == "${{ env.LatestMATLABVersion }}";
64-
addpath(genpath("tools")), testToolbox("CreateBadge", doCreateBadge)
68+
addpath(genpath("tools")); testToolbox("CreateBadge", doCreateBadge)
6569
6670
# Commit updated SVG badges for the issues and tests (if changed)
6771
- name: Commit svg badges if updated
6872
if: matrix.MATLABVersion == env.LatestMATLABVersion
6973
continue-on-error: true
7074
run: |
7175
git config user.name "${{ github.workflow }} by ${{ github.actor }}"
72-
git config user.email "<>"
76+
git config user.email "${{ secrets.COMMIT_EMAIL_ADDRESS }}"
7377
git fetch
7478
7579
if [[ $(git add .github/badges/* --dry-run | wc -l) -gt 0 ]]; then

0 commit comments

Comments
 (0)