Skip to content

Commit 3fd85d6

Browse files
Add a format gate in CI (#21)
* Add format gate in CI * fix formatter findings * add contribuing and run npm audit fix * sanitize * Address doc feedback * Bump handlebars from 4.7.8 to 4.7.9 Bumps [handlebars](https://github.com/handlebars-lang/handlebars.js) from 4.7.8 to 4.7.9. - [Release notes](https://github.com/handlebars-lang/handlebars.js/releases) - [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/v4.7.9/release-notes.md) - [Commits](handlebars-lang/handlebars.js@v4.7.8...v4.7.9) --- updated-dependencies: - dependency-name: handlebars dependency-version: 4.7.9 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * rebase * npm audit fix * run format * fix contributing * remove end of line whitespace * update workflow --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 6bb398e commit 3fd85d6

16 files changed

Lines changed: 468 additions & 327 deletions

.github/workflows/bat.yml

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
1-
name: Build and Test
2-
on: [push]
3-
permissions:
4-
contents: read
5-
6-
jobs:
7-
plugin-tests:
8-
runs-on: ${{ matrix.os }}
9-
strategy:
10-
fail-fast: false
11-
matrix:
12-
include:
13-
- os: ubuntu-latest
14-
- os: windows-latest
15-
- os: macos-latest
16-
steps:
17-
- uses: actions/checkout@v6
18-
- uses: matlab-actions/setup-matlab@v2
19-
with:
20-
release: latest-including-prerelease
21-
- uses: matlab-actions/run-tests@v2
22-
with:
23-
source-folder: plugins
24-
25-
bat:
26-
name: Build and Test
27-
runs-on: ubuntu-22.04
28-
steps:
29-
- uses: actions/checkout@v6
30-
- uses: actions/setup-node@v6
31-
with:
32-
node-version: 24
33-
- name: Perform npm tasks
34-
run: npm run ci
35-
1+
name: Build and Test
2+
on: [push]
3+
permissions:
4+
contents: read
5+
6+
jobs:
7+
plugin-tests:
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
include:
13+
- os: ubuntu-latest
14+
- os: windows-latest
15+
- os: macos-latest
16+
steps:
17+
- uses: actions/checkout@v6
18+
- uses: matlab-actions/setup-matlab@v3
19+
with:
20+
release: latest-including-prerelease
21+
- uses: matlab-actions/run-tests@v3
22+
with:
23+
source-folder: plugins
24+
25+
bat:
26+
name: Build and Test
27+
runs-on: ubuntu-24.04
28+
steps:
29+
- uses: actions/checkout@v6
30+
- uses: actions/setup-node@v6
31+
with:
32+
node-version: 24
33+
- name: Perform npm tasks
34+
run: npm run ci

.github/workflows/publish.yml

Lines changed: 77 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,77 @@
1-
name: Publish
2-
on:
3-
release:
4-
types: published
5-
permissions:
6-
contents: write
7-
8-
jobs:
9-
build:
10-
name: Build
11-
runs-on: ubuntu-latest
12-
outputs:
13-
tag: ${{ steps.update-package-version.outputs.version }}
14-
steps:
15-
- uses: actions/checkout@v6
16-
- name: Configure git
17-
run: |
18-
git config user.name 'Release Action'
19-
git config user.email '<>'
20-
- uses: actions/setup-node@v6
21-
with:
22-
node-version: 24
23-
24-
# Call `npm version`. It increments the version and commits the changes.
25-
# We'll save the output (new version string) for use in the following
26-
# steps
27-
- name: Update package version
28-
id: update-package-version
29-
run: |
30-
git tag -d "${{ github.event.release.tag_name }}"
31-
VERSION=$(npm version "${{ github.event.release.tag_name }}" --no-git-tag-version)
32-
git add package.json package-lock.json
33-
git commit -m "[skip ci] Bump $VERSION"
34-
git push origin HEAD:main
35-
36-
# Now carry on, business as usual
37-
- name: Perform npm tasks
38-
run: npm run ci
39-
40-
# Finally, create a detached commit containing the built artifacts and tag
41-
# it with the release. Note: the fact that the branch is locally updated
42-
# will not be relayed (pushed) to origin
43-
- name: Commit to release branch
44-
id: release_info
45-
run: |
46-
# Check for semantic versioning
47-
longVersion="${{github.event.release.tag_name}}"
48-
echo "Preparing release for version $longVersion"
49-
[[ $longVersion == v[0-9]*.[0-9]*.[0-9]* ]] || (echo "must follow semantic versioning" && exit 1)
50-
majorVersion=$(echo ${longVersion%.*.*})
51-
minorVersion=$(echo ${longVersion%.*})
52-
53-
# Add the built artifacts. Using --force because dist/lib should be in
54-
# .gitignore
55-
git add --force dist lib
56-
57-
# Make the commit
58-
MESSAGE="Build for $(git rev-parse --short HEAD)"
59-
git commit --allow-empty -m "$MESSAGE"
60-
git tag -f -a -m "Release $longVersion" $longVersion
61-
62-
# Get the commit of the tag you just released
63-
commitHash=$(git rev-list -n 1 $longVersion)
64-
65-
# Delete the old major and minor version tags locally
66-
git tag -d $majorVersion || true
67-
git tag -d $minorVersion || true
68-
69-
# Make new major and minor version tags locally that point to the commit you got from the "git rev-list" above
70-
git tag -f $majorVersion $commitHash
71-
git tag -f $minorVersion $commitHash
72-
73-
# Force push the new minor version tag to overwrite the old tag remotely
74-
echo "Pushing new tags"
75-
git push -f origin $longVersion
76-
git push -f origin $majorVersion
77-
git push -f origin $minorVersion
1+
name: Publish
2+
on:
3+
release:
4+
types: published
5+
permissions:
6+
contents: write
7+
8+
jobs:
9+
build:
10+
name: Build
11+
runs-on: ubuntu-latest
12+
outputs:
13+
tag: ${{ steps.update-package-version.outputs.version }}
14+
steps:
15+
- uses: actions/checkout@v6
16+
- name: Configure git
17+
run: |
18+
git config user.name 'Release Action'
19+
git config user.email '<>'
20+
- uses: actions/setup-node@v6
21+
with:
22+
node-version: 24
23+
24+
# Call `npm version`. It increments the version and commits the changes.
25+
# We'll save the output (new version string) for use in the following
26+
# steps
27+
- name: Update package version
28+
id: update-package-version
29+
run: |
30+
git tag -d "${{ github.event.release.tag_name }}"
31+
VERSION=$(npm version "${{ github.event.release.tag_name }}" --no-git-tag-version)
32+
git add package.json package-lock.json
33+
git commit -m "[skip ci] Bump $VERSION"
34+
git push origin HEAD:main
35+
36+
# Now carry on, business as usual
37+
- name: Perform npm tasks
38+
run: npm run ci
39+
40+
# Finally, create a detached commit containing the built artifacts and tag
41+
# it with the release. Note: the fact that the branch is locally updated
42+
# will not be relayed (pushed) to origin
43+
- name: Commit to release branch
44+
id: release_info
45+
run: |
46+
# Check for semantic versioning
47+
longVersion="${{github.event.release.tag_name}}"
48+
echo "Preparing release for version $longVersion"
49+
[[ $longVersion == v[0-9]*.[0-9]*.[0-9]* ]] || (echo "must follow semantic versioning" && exit 1)
50+
majorVersion=$(echo ${longVersion%.*.*})
51+
minorVersion=$(echo ${longVersion%.*})
52+
53+
# Add the built artifacts. Using --force because dist/lib should be in
54+
# .gitignore
55+
git add --force dist lib
56+
57+
# Make the commit
58+
MESSAGE="Build for $(git rev-parse --short HEAD)"
59+
git commit --allow-empty -m "$MESSAGE"
60+
git tag -f -a -m "Release $longVersion" $longVersion
61+
62+
# Get the commit of the tag you just released
63+
commitHash=$(git rev-list -n 1 $longVersion)
64+
65+
# Delete the old major and minor version tags locally
66+
git tag -d $majorVersion || true
67+
git tag -d $minorVersion || true
68+
69+
# Make new major and minor version tags locally that point to the commit you got from the "git rev-list" above
70+
git tag -f $majorVersion $commitHash
71+
git tag -f $minorVersion $commitHash
72+
73+
# Force push the new minor version tag to overwrite the old tag remotely
74+
echo "Pushing new tags"
75+
git push -f origin $longVersion
76+
git push -f origin $majorVersion
77+
git push -f origin $minorVersion

devel/contributing.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## Contributing
2+
3+
Verify changes by running tests and building locally with the following command:
4+
5+
```
6+
npm run ci
7+
```
8+
9+
## Creating a New Release
10+
11+
Familiarize yourself with the best practices for [releasing and maintaining GitHub actions](https://docs.github.com/en/actions/creating-actions/releasing-and-maintaining-actions).
12+
13+
Changes should be made on a new branch. The new branch should be merged to the main branch via a pull request. Ensure that all of the CI pipeline checks and tests have passed for your changes.
14+
15+
After the pull request has been approved and merged to main, follow the Github process for [creating a new release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository). The release must follow semantic versioning (ex: vX.Y.Z). This will kick off a new pipeline execution, and the action will automatically be published to the GitHub Actions Marketplace if the pipeline finishes successfully. Check the [GitHub Marketplace](https://github.com/marketplace/actions/setup-matlab) and check the major version in the repository (ex: v1 for v1.0.0) to ensure that the new semantically versioned tag is available.
16+
17+
## Adding a Pre-Commit Hook
18+
19+
You can run all CI checks before each commit by adding a pre-commit hook. To do so, navigate to the repository root folder and run the following commands:
20+
21+
_bash (Linux/macOS)_
22+
23+
```sh
24+
echo '#!/bin/sh' > .git/hooks/pre-commit
25+
echo 'npm run ci' >> .git/hooks/pre-commit
26+
chmod +x .git/hooks/pre-commit
27+
```
28+
29+
_Command Prompt (Windows)_
30+
31+
```cmd
32+
echo #!/bin/sh > .git\hooks\pre-commit
33+
echo npm run ci >> .git\hooks\pre-commit
34+
```
35+
36+
_PowerShell (Windows)_
37+
38+
```pwsh
39+
Set-Content .git\hooks\pre-commit '#!/bin/sh'
40+
Add-Content .git\hooks\pre-commit 'npm run ci'
41+
```
42+
43+
> **Note:**
44+
> Git hooks are not version-controlled, so you need to set up this hook for each fresh clone of the repository.

jest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default {
1414
},
1515
],
1616
},
17-
extensionsToTreatAsEsm: ['.ts'],
17+
extensionsToTreatAsEsm: [".ts"],
1818
transformIgnorePatterns: ["node_modules/(?!(@actions)/)"],
1919
moduleNameMapper: {
2020
"^(\\.{1,2}/.*)\\.js$": "$1",

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"prepare": "npm run build",
1414
"package": "ncc build --minify",
1515
"test": "NODE_OPTIONS='--experimental-vm-modules' jest",
16-
"all": "npm test && npm run build && npm run package",
16+
"all": "npm run format-check && npm test && npm run build && npm run package",
1717
"ci": "npm run clean && npm ci --ignore-scripts && npm run all"
1818
},
1919
"files": [

0 commit comments

Comments
 (0)