diff --git a/.github/workflows/commitlint.config.js b/.github/workflows/commitlint.config.cjs similarity index 100% rename from .github/workflows/commitlint.config.js rename to .github/workflows/commitlint.config.cjs diff --git a/.github/workflows/ocpl_cm_standards_check.yml b/.github/workflows/ocpl_cm_standards_check.yml index 3782627..31a4175 100644 --- a/.github/workflows/ocpl_cm_standards_check.yml +++ b/.github/workflows/ocpl_cm_standards_check.yml @@ -2,30 +2,45 @@ name: OCPL Configuration Management Standards Check (Shared) on: workflow_call: - + inputs: + config_ref: + required: true + type: string + description: 'The branch, tag, or commit hash to use when retrieving the commitlint configuration file from the NCIOCPL/.github repository.' + +permissions: + contents: read + jobs: - # use commitlint to verify git commit messages - # settings are in commitlint.config.js + commitlint: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 + - name: Setup node + uses: actions/setup-node@v6 with: - fetch-depth: 0 - # need to check out the repo to get the config file - # could alternatively download the single file via a script action - - name: Checkout commitlint config - uses: actions/checkout@v3 + node-version: 'lts/jod' + + - name: Install commitlint + run: npm install -g @commitlint/cli@20 + + - name: Copy config file + id: configFile + run: | + tempdir=$(mktemp -d) + configFile="$tempdir/commitlint.config.cjs" + curl -fsSL "https://raw.githubusercontent.com/NCIOCPL/.github/refs/heads/${{ inputs.config_ref }}/.github/workflows/commitlint.config.cjs" -o "$configFile" + echo "CONFIG_FILE=$configFile" >> $GITHUB_OUTPUT + + - name: Checkout code + uses: actions/checkout@v5 with: - repository: NCIOCPL/.github - # This URL will need to be updated when we want to bump to a new version - ref: workflow/v2 - path: commitlint + fetch-depth: 0 + - name: Commitlint - uses: wagoid/commitlint-github-action@v5 - with: - configFile: ./commitlint/.github/workflows/commitlint.config.js + if: github.event_name == 'pull_request' + run: | + commitlint --config ${{ steps.configFile.outputs.CONFIG_FILE }} --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose ## Holding off on PR checking until we can fully verify them diff --git a/.github/workflows/test_commitlint.yml b/.github/workflows/test_commitlint.yml index b7a821e..17ce95a 100644 --- a/.github/workflows/test_commitlint.yml +++ b/.github/workflows/test_commitlint.yml @@ -7,12 +7,17 @@ on: concurrency: group: ${{ github.ref }} cancel-in-progress: true - + jobs: #commitlint commitlint commitlint_remote: - uses: nciocpl/.github/.github/workflows/ocpl_cm_standards_check.yml@workflow/v2 + # The github context isn't recognized in the ref for the called workflow, + # so we'll have to leave that one hard-coded for now. + #uses: nciocpl/.github/.github/workflows/ocpl_cm_standards_check.yml@workflow/v4 + uses: nciocpl/.github/.github/workflows/ocpl_cm_standards_check.yml@ticket/14-module-fix + with: + config_ref: '${{ github.head_ref }}' test: name: Test commitlint rules @@ -20,12 +25,12 @@ jobs: steps: - name: Checkout branch - uses: actions/checkout@v3 + uses: actions/checkout@v5 - name: Setup node - uses: actions/setup-node@v3 + uses: actions/setup-node@v6 with: - node-version: '18' + node-version: 'lts/jod' - name: Install commitlint run: npm install -g commitlint diff --git a/foo b/foo new file mode 100644 index 0000000..e69de29 diff --git a/test.sh b/test.sh index 4ebf9af..182956c 100755 --- a/test.sh +++ b/test.sh @@ -11,11 +11,11 @@ fi for f in ./tests/positive*.txt do echo "==========================================" - cat "$f" | $commitlintcmd -q -g ./.github/workflows/commitlint.config.js + cat "$f" | $commitlintcmd -q -g ./.github/workflows/commitlint.config.cjs if [ $? != 0 ]; then testStatus=1 echo "Failed: Test $f produced a failing commitlint (unexpected)." - cat "$f" | $commitlintcmd -V -g ./.github/workflows/commitlint.config.js + cat "$f" | $commitlintcmd -V -g ./.github/workflows/commitlint.config.cjs else echo "Passed: Test $f" fi @@ -24,11 +24,11 @@ done for f in ./tests/negative*.txt do echo "==========================================" - cat "$f" | $commitlintcmd -q -g ./.github/workflows/commitlint.config.js + cat "$f" | $commitlintcmd -q -g ./.github/workflows/commitlint.config.cjs if [ $? == 0 ]; then testStatus=1 echo "Failed: Test $f produced a passing commitlint (unexpected)." - cat "$f" | $commitlintcmd -V -g ./.github/workflows/commitlint.config.js + cat "$f" | $commitlintcmd -V -g ./.github/workflows/commitlint.config.cjs echo "and after" else echo "Passed: Test $f"