From dd5c4cab9ed33560cede60553bdfb44a2900390f Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Thu, 2 May 2024 14:31:33 +0100 Subject: [PATCH 01/16] Fix linting --- .all-contributorsrc | 34 ++++++-------------------------- .github/workflows/checkcode.yaml | 26 ++++++++++++++++++++++++ .markdownlint.taml | 0 README.md | 15 ++++++++------ 4 files changed, 41 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/checkcode.yaml create mode 100644 .markdownlint.taml diff --git a/.all-contributorsrc b/.all-contributorsrc index de0d7b7..048e04e 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,9 +1,7 @@ { "projectName": "matlab-project-template", "projectOwner": "reproducibleMATLAB", - "files": [ - ".github/README.md" - ], + "files": [".github/README.md"], "commitType": "docs", "commitConvention": "angular", "contributorsPerLine": 7, @@ -13,55 +11,35 @@ "name": "Gaurav Bhalerao", "avatar_url": "https://avatars.githubusercontent.com/u/34817097?v=4", "profile": "https://github.com/gvbhalerao591", - "contributions": [ - "ideas", - "content", - "code" - ] + "contributions": ["ideas", "content", "code"] }, { "login": "paddyroddy", "name": "Patrick J. Roddy", "avatar_url": "https://avatars.githubusercontent.com/u/15052188?v=4", "profile": "https://paddyroddy.github.io", - "contributions": [ - "ideas", - "content", - "code" - ] + "contributions": ["ideas", "content", "code"] }, { "login": "dc2917", "name": "Dan Cummins", "avatar_url": "https://avatars.githubusercontent.com/u/45606273?v=4", "profile": "https://dc2917.github.io", - "contributions": [ - "ideas", - "content", - "code" - ] + "contributions": ["ideas", "content", "code"] }, { "login": "cmtso", "name": "Michael Tso", "avatar_url": "https://avatars.githubusercontent.com/u/37928699?v=4", "profile": "http://cmtso.github.io", - "contributions": [ - "ideas", - "content", - "code" - ] + "contributions": ["ideas", "content", "code"] }, { "login": "davidwilby", "name": "David Wilby", "avatar_url": "https://avatars.githubusercontent.com/u/24752124?v=4", "profile": "http://davidwilby.dev", - "contributions": [ - "ideas", - "content", - "code" - ] + "contributions": ["ideas", "content", "code"] } ] } diff --git a/.github/workflows/checkcode.yaml b/.github/workflows/checkcode.yaml new file mode 100644 index 0000000..f0683dc --- /dev/null +++ b/.github/workflows/checkcode.yaml @@ -0,0 +1,26 @@ +--- +name: Checkcode + +on: + push: + branches: + - main + pull_request: + +concurrency: + cancel-in-progress: true + group: >- + ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + +jobs: + checkcode: + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@v4 + + - name: Set up MATLAB + uses: matlab-actions/setup-matlab@v2 + + - name: Run tests + uses: matlab-actions/run-tests@v2 diff --git a/.markdownlint.taml b/.markdownlint.taml new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index 0b1ba71..e6d75e1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # PROJECT-NAME -(Add one line summary of what it does) +(Add one line summary of what it does) ## TODO Upon Project Creation @@ -21,21 +21,24 @@ First, clone this repository: -``` -# Clone this repository +```sh git clone https://github.com//.git cd ``` -Alternatively, download the code as a .zip folder by clicking the "Code" button on GitHub. +Alternatively, download the code as a .zip folder by clicking the "Code" button +on GitHub. ## Contributing - is an open-source project and we welcome contributions from the community. + is an open-source +project and we welcome contributions from the community. -If you'd like to contribute, please fork the repository and make changes as you'd like. Pull requests are warmly welcome. +If you'd like to contribute, please fork the repository and make changes as +you'd like. Pull requests are warmly welcome. ### Our Contributors + From 0178ba90a10dc50ad80af7636edfcb7f10502d04 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Thu, 2 May 2024 14:32:55 +0100 Subject: [PATCH 02/16] Remove markdownlint --- .markdownlint.taml | 0 README.md | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 .markdownlint.taml diff --git a/.markdownlint.taml b/.markdownlint.taml deleted file mode 100644 index e69de29..0000000 diff --git a/README.md b/README.md index e6d75e1..f5ecd23 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,8 @@ on GitHub. ## Contributing - is an open-source -project and we welcome contributions from the community. + is an open-source +project, and we welcome contributions from the community. If you'd like to contribute, please fork the repository and make changes as you'd like. Pull requests are warmly welcome. From 58437af4e2557c28fc97b994c372cdb1e57cca26 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Thu, 2 May 2024 14:34:45 +0100 Subject: [PATCH 03/16] Run `mlintrpt` function --- .github/workflows/checkcode.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checkcode.yaml b/.github/workflows/checkcode.yaml index f0683dc..3d5660e 100644 --- a/.github/workflows/checkcode.yaml +++ b/.github/workflows/checkcode.yaml @@ -22,5 +22,7 @@ jobs: - name: Set up MATLAB uses: matlab-actions/setup-matlab@v2 - - name: Run tests - uses: matlab-actions/run-tests@v2 + - name: Run command + uses: matlab-actions/run-command@v2 + with: + command: mlintrpt From f6b7ddf8900b4ee1e79b505dd7a9b1c1490923dd Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Thu, 2 May 2024 15:14:48 +0100 Subject: [PATCH 04/16] Run `mlintpt` over all folders --- .github/workflows/checkcode.yaml | 22 ++++++++++++++++++++-- tests/source/scripts/main.m | 2 +- tests/source/scripts/mainRun.m | 2 +- tests/source/scripts/mainTest.m | 1 - 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/checkcode.yaml b/.github/workflows/checkcode.yaml index 3d5660e..9142281 100644 --- a/.github/workflows/checkcode.yaml +++ b/.github/workflows/checkcode.yaml @@ -13,16 +13,34 @@ concurrency: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} jobs: - checkcode: + directories: runs-on: ubuntu-latest steps: - name: Checkout source uses: actions/checkout@v4 + - name: Get directories + id: directories + run: >- + echo directories=$(find . -type d -mindepth 1 -not -path '*/\.*' | sed + 's/.\///' | tr '\n' ',' | sed 's/,$//') >> $GITHUB_OUTPUT + outputs: + dirs: ${{ steps.directories.outputs.directories }} + + checkcode: + needs: directories + runs-on: ubuntu-latest + strategy: + matrix: + dir: ${{ fromJson(needs.directories.outputs.dirs) }} + steps: - name: Set up MATLAB uses: matlab-actions/setup-matlab@v2 - - name: Run command + - name: Move into $dir directory + run: cd $dir + + - name: Run MATLAB Command uses: matlab-actions/run-command@v2 with: command: mlintrpt diff --git a/tests/source/scripts/main.m b/tests/source/scripts/main.m index 2625fd4..df3f6c9 100644 --- a/tests/source/scripts/main.m +++ b/tests/source/scripts/main.m @@ -2,4 +2,4 @@ function out = main(variable) % your code here % -end \ No newline at end of file +end diff --git a/tests/source/scripts/mainRun.m b/tests/source/scripts/mainRun.m index a68ace0..d08c87b 100644 --- a/tests/source/scripts/mainRun.m +++ b/tests/source/scripts/mainRun.m @@ -1,2 +1,2 @@ % Execute the runtests function to run the four tests in main.m -results = runtests('main'); \ No newline at end of file +results = runtests('main'); diff --git a/tests/source/scripts/mainTest.m b/tests/source/scripts/mainTest.m index fb3f902..a7639d8 100644 --- a/tests/source/scripts/mainTest.m +++ b/tests/source/scripts/mainTest.m @@ -3,4 +3,3 @@ % This unit test can use assert to check different outputs of main % function - From 1f2d2e815dc8a9df75253373e40eeab85e488f87 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Thu, 2 May 2024 15:22:29 +0100 Subject: [PATCH 05/16] Fix linting --- .github/README.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/README.md b/.github/README.md index 8111cce..2a79647 100644 --- a/.github/README.md +++ b/.github/README.md @@ -1,12 +1,22 @@ # matlab-project-template -This is a template repository you can use for your MATLAB software project. It pre-populates essential files and directory structure when you use this template to create the repository for your project. + +This is a template repository you can use for your MATLAB software project. It +pre-populates essential files and directory structure when you use this template +to create the repository for your project. ## Getting started -Click **Use this template**, then select **Create a new repository** and then fill in the essential information for your repository. Then a repository that utilises this template will be created for you. -More detailed instructions can be found [here]('https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template'). + +Click **Use this template**, then select **Create a new repository** and then +fill in the essential information for your repository. Then a repository that +utilises this template will be created for you. More detailed instructions can +be found +[here]('https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template'). ## After the repository has been created -You will need to make changes to some of the placeholder content in the files in your new repository. See more instructions in the README file in the new repository. + +You will need to make changes to some of the placeholder content in the files in +your new repository. See more instructions in the README file in the new +repository. ## Contributors From 69eaa0d1b603ef51449965fb79196fd328a88497 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Thu, 2 May 2024 15:38:20 +0100 Subject: [PATCH 06/16] Fix loop --- .github/workflows/checkcode.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checkcode.yaml b/.github/workflows/checkcode.yaml index 9142281..9727e5d 100644 --- a/.github/workflows/checkcode.yaml +++ b/.github/workflows/checkcode.yaml @@ -22,8 +22,8 @@ jobs: - name: Get directories id: directories run: >- - echo directories=$(find . -type d -mindepth 1 -not -path '*/\.*' | sed - 's/.\///' | tr '\n' ',' | sed 's/,$//') >> $GITHUB_OUTPUT + echo directories=$(find . -type d -mindepth 1 -not -path '*/\.*') >> + $GITHUB_OUTPUT outputs: dirs: ${{ steps.directories.outputs.directories }} @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - dir: ${{ fromJson(needs.directories.outputs.dirs) }} + dir: ${{ needs.directories.outputs.dirs }} steps: - name: Set up MATLAB uses: matlab-actions/setup-matlab@v2 From ad9c02d36d251d657a645a8e911bf237e988a495 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Thu, 2 May 2024 15:50:37 +0100 Subject: [PATCH 07/16] Fix loop --- .github/workflows/checkcode.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checkcode.yaml b/.github/workflows/checkcode.yaml index 9727e5d..455edcc 100644 --- a/.github/workflows/checkcode.yaml +++ b/.github/workflows/checkcode.yaml @@ -22,8 +22,8 @@ jobs: - name: Get directories id: directories run: >- - echo directories=$(find . -type d -mindepth 1 -not -path '*/\.*') >> - $GITHUB_OUTPUT + echo directories=[$(find . -type d -mindepth 1 -not -path '*/\.*' | + sed 's/^..//' | tr '\n' ',' | sed 's/,$//')] >> $GITHUB_OUTPUT outputs: dirs: ${{ steps.directories.outputs.directories }} From 707866b85a0c3cc81d066989d928b1643c87ed92 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Thu, 2 May 2024 15:52:26 +0100 Subject: [PATCH 08/16] Use `fromJson` --- .github/workflows/checkcode.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checkcode.yaml b/.github/workflows/checkcode.yaml index 455edcc..fbcaea0 100644 --- a/.github/workflows/checkcode.yaml +++ b/.github/workflows/checkcode.yaml @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - dir: ${{ needs.directories.outputs.dirs }} + dir: ${{ fromJson(needs.directories.outputs.dirs) }} steps: - name: Set up MATLAB uses: matlab-actions/setup-matlab@v2 From 4620853425612a66fd1b1d824286b70d71d2f0cb Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Thu, 2 May 2024 16:04:36 +0100 Subject: [PATCH 09/16] Tidy --- .github/workflows/checkcode.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/checkcode.yaml b/.github/workflows/checkcode.yaml index fbcaea0..efbdfb1 100644 --- a/.github/workflows/checkcode.yaml +++ b/.github/workflows/checkcode.yaml @@ -25,20 +25,20 @@ jobs: echo directories=[$(find . -type d -mindepth 1 -not -path '*/\.*' | sed 's/^..//' | tr '\n' ',' | sed 's/,$//')] >> $GITHUB_OUTPUT outputs: - dirs: ${{ steps.directories.outputs.directories }} + directories: ${{ steps.directories.outputs.directories }} checkcode: needs: directories runs-on: ubuntu-latest strategy: matrix: - dir: ${{ fromJson(needs.directories.outputs.dirs) }} + directory: ${{ fromJson(needs.directories.outputs.directories) }} steps: - name: Set up MATLAB uses: matlab-actions/setup-matlab@v2 - - name: Move into $dir directory - run: cd $dir + - name: Move into ${{ matrix.directory }} directory + run: cd ${{ matrix.directory }} - name: Run MATLAB Command uses: matlab-actions/run-command@v2 From b3e3c739b49bd0c860ae44eafc87f3d1f777dd3b Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Thu, 2 May 2024 16:26:56 +0100 Subject: [PATCH 10/16] Try `sed` instead --- .github/workflows/checkcode.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checkcode.yaml b/.github/workflows/checkcode.yaml index efbdfb1..8b78455 100644 --- a/.github/workflows/checkcode.yaml +++ b/.github/workflows/checkcode.yaml @@ -23,7 +23,7 @@ jobs: id: directories run: >- echo directories=[$(find . -type d -mindepth 1 -not -path '*/\.*' | - sed 's/^..//' | tr '\n' ',' | sed 's/,$//')] >> $GITHUB_OUTPUT + sed 's/^..//' | sed -z 's/\n/, /g' | sed 's/, $//')] >> $GITHUB_OUTPUT outputs: directories: ${{ steps.directories.outputs.directories }} From c211697028f42e57bf4353dbb56e4512d9ab6876 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Thu, 2 May 2024 16:32:23 +0100 Subject: [PATCH 11/16] Remove `fromJson` --- .github/workflows/checkcode.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checkcode.yaml b/.github/workflows/checkcode.yaml index 8b78455..e8bafd5 100644 --- a/.github/workflows/checkcode.yaml +++ b/.github/workflows/checkcode.yaml @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - directory: ${{ fromJson(needs.directories.outputs.directories) }} + directory: ${{ needs.directories.outputs.directories }} steps: - name: Set up MATLAB uses: matlab-actions/setup-matlab@v2 From ff60d93779e8589d86c1ed6fe5163601a61a8c4b Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Thu, 2 May 2024 16:38:13 +0100 Subject: [PATCH 12/16] Test if it works --- .github/workflows/checkcode.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checkcode.yaml b/.github/workflows/checkcode.yaml index e8bafd5..54ac9af 100644 --- a/.github/workflows/checkcode.yaml +++ b/.github/workflows/checkcode.yaml @@ -22,8 +22,9 @@ jobs: - name: Get directories id: directories run: >- - echo directories=[$(find . -type d -mindepth 1 -not -path '*/\.*' | - sed 's/^..//' | sed -z 's/\n/, /g' | sed 's/, $//')] >> $GITHUB_OUTPUT + echo "directories=["$(find . -type d -mindepth 1 -not -path '*/\.*' | + sed 's/^..//' | sed -z 's/\n/","/g' | sed 's/,$//')"]" >> + $GITHUB_OUTPUT outputs: directories: ${{ steps.directories.outputs.directories }} @@ -32,7 +33,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - directory: ${{ needs.directories.outputs.directories }} + directory: ${{ fromJson(needs.directories.outputs.directories) }} steps: - name: Set up MATLAB uses: matlab-actions/setup-matlab@v2 From f712ea5af936c51ab859b870f14dda82b2bad90c Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Thu, 2 May 2024 16:41:07 +0100 Subject: [PATCH 13/16] Fix --- .github/workflows/checkcode.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checkcode.yaml b/.github/workflows/checkcode.yaml index 54ac9af..abe89ce 100644 --- a/.github/workflows/checkcode.yaml +++ b/.github/workflows/checkcode.yaml @@ -22,8 +22,8 @@ jobs: - name: Get directories id: directories run: >- - echo "directories=["$(find . -type d -mindepth 1 -not -path '*/\.*' | - sed 's/^..//' | sed -z 's/\n/","/g' | sed 's/,$//')"]" >> + echo "directories=[$(find . -type d -mindepth 1 -not -path '*/\.*' | + sed 's/^..//' | sed -z 's/\n/, /g' | sed 's/, $//')]" >> $GITHUB_OUTPUT outputs: directories: ${{ steps.directories.outputs.directories }} From 7efd3c2e0429950d58f52de1a733c35913a964af Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Thu, 2 May 2024 17:01:17 +0100 Subject: [PATCH 14/16] Use `jq` --- .github/workflows/checkcode.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checkcode.yaml b/.github/workflows/checkcode.yaml index abe89ce..902383d 100644 --- a/.github/workflows/checkcode.yaml +++ b/.github/workflows/checkcode.yaml @@ -22,9 +22,8 @@ jobs: - name: Get directories id: directories run: >- - echo "directories=[$(find . -type d -mindepth 1 -not -path '*/\.*' | - sed 's/^..//' | sed -z 's/\n/, /g' | sed 's/, $//')]" >> - $GITHUB_OUTPUT + echo directories=$(ind . -type d -mindepth 1 -not -path '*/\.*' | sed + 's/^..//' | jq -R -s -c 'split("\n")[:-1]') >> $GITHUB_OUTPUT outputs: directories: ${{ steps.directories.outputs.directories }} From 14c1344b1ad546a3374602ecf2f75081fdaccf6e Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Thu, 2 May 2024 17:02:11 +0100 Subject: [PATCH 15/16] Missing f --- .github/workflows/checkcode.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checkcode.yaml b/.github/workflows/checkcode.yaml index 902383d..fb0635a 100644 --- a/.github/workflows/checkcode.yaml +++ b/.github/workflows/checkcode.yaml @@ -22,7 +22,7 @@ jobs: - name: Get directories id: directories run: >- - echo directories=$(ind . -type d -mindepth 1 -not -path '*/\.*' | sed + echo directories=$(find . -type d -mindepth 1 -not -path '*/\.*' | sed 's/^..//' | jq -R -s -c 'split("\n")[:-1]') >> $GITHUB_OUTPUT outputs: directories: ${{ steps.directories.outputs.directories }} From be5d19c785cbfa1503615c0e853179fef30a04d3 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 3 May 2024 09:48:37 +0100 Subject: [PATCH 16/16] Checkout code --- .github/workflows/checkcode.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checkcode.yaml b/.github/workflows/checkcode.yaml index fb0635a..9e51968 100644 --- a/.github/workflows/checkcode.yaml +++ b/.github/workflows/checkcode.yaml @@ -34,11 +34,14 @@ jobs: matrix: directory: ${{ fromJson(needs.directories.outputs.directories) }} steps: + - name: Checkout source + uses: actions/checkout@v4 + - name: Set up MATLAB uses: matlab-actions/setup-matlab@v2 - name: Move into ${{ matrix.directory }} directory - run: cd ${{ matrix.directory }} + run: cd ${{ github.workspace }}/${{ matrix.directory }} - name: Run MATLAB Command uses: matlab-actions/run-command@v2