Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 32 additions & 17 deletions .github/workflows/ocpl_cm_standards_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/test_commitlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,30 @@ 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
runs-on: ubuntu-latest
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
Expand Down
Empty file added foo
Empty file.
8 changes: 4 additions & 4 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
Loading