From 5af21fddcc2862954f2d5e6b8f11597ba24d75d4 Mon Sep 17 00:00:00 2001 From: Loren Gordon Date: Mon, 23 Jan 2023 07:50:49 -0800 Subject: [PATCH 1/3] Adds inputs for lint/release and reuses workflows locally --- .github/workflows/lint.yml | 13 ++--- .github/workflows/local-lint.yml | 11 ++++ .github/workflows/local-release.yml | 18 +++++++ .github/workflows/local-test.yml | 11 ++++ .github/workflows/release.yml | 17 +++---- .github/workflows/test.yml | 5 -- README.md | 79 ++++++++++++++++++++++++++++- 7 files changed, 132 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/local-lint.yml create mode 100644 .github/workflows/local-release.yml create mode 100644 .github/workflows/local-test.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c0cfae9..9f138e5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,11 +1,12 @@ name: Run lint and static analyis checks on: - pull_request: workflow_call: - -concurrency: - group: lint-${{ github.head_ref || github.ref }} - cancel-in-progress: true + inputs: + tardigradelint-target: + description: Name of the Tardigrade-CI target to run + default: lint + required: false + type: string jobs: tardigradelint: @@ -15,7 +16,7 @@ jobs: uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - name: Project Syntax Verification - run: make docker/run target=lint + run: make docker/run target=${{ inputs.tardigradelint-target }} actionlint: runs-on: ubuntu-latest diff --git a/.github/workflows/local-lint.yml b/.github/workflows/local-lint.yml new file mode 100644 index 0000000..406751b --- /dev/null +++ b/.github/workflows/local-lint.yml @@ -0,0 +1,11 @@ +name: Run lint and static analyis checks +on: + pull_request: + +concurrency: + group: lint-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + lint: + uses: ./.github/workflows/lint.yml diff --git a/.github/workflows/local-release.yml b/.github/workflows/local-release.yml new file mode 100644 index 0000000..6846f5d --- /dev/null +++ b/.github/workflows/local-release.yml @@ -0,0 +1,18 @@ +name: Create GitHub Release + +on: + # Run on demand + workflow_dispatch: + + # Run on push to main when .bumpversion.cfg version is updated + push: + branches: + - main + paths: + - .bumpversion.cfg + +jobs: + release: + uses: ./.github/workflows/release.yml + secrets: + release-token: ${{ secrets.GH_RELEASES_TOKEN }} diff --git a/.github/workflows/local-test.yml b/.github/workflows/local-test.yml new file mode 100644 index 0000000..7b86b6d --- /dev/null +++ b/.github/workflows/local-test.yml @@ -0,0 +1,11 @@ +name: Run test jobs +on: + pull_request: + +concurrency: + group: test-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + test: + uses: ./.github/workflows/test.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 931d424..52d3466 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,15 +1,12 @@ name: Create GitHub Release on: - # Run on demand - workflow_dispatch: - - # Run on push to main when .bumpversion.cfg version is updated - push: - branches: - - main - paths: - - .bumpversion.cfg + # Run as a reusable workflow + workflow_call: + secrets: + release-token: + description: Token with permissions to create GitHub Releases + required: true jobs: lint: @@ -51,4 +48,4 @@ jobs: tag_name: ${{ steps.release.outputs.version }} generate_release_notes: true target_commitish: ${{ env.GITHUB_REF }} - token: ${{ secrets.GH_RELEASES_TOKEN }} + token: ${{ secrets.release-token }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f019293..fff8758 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,12 +1,7 @@ name: Run test jobs on: - pull_request: workflow_call: -concurrency: - group: test-${{ github.head_ref || github.ref }} - cancel-in-progress: true - jobs: mockstacktest: runs-on: ubuntu-latest diff --git a/README.md b/README.md index 64a793a..aab1dec 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,79 @@ # actions-workflows -Repository of plus3it reusable worfklows for GitHub Actions +Repository of plus3it reusable worfklows for GitHub Actions. + +This project publishes reusable workflows for the Plus3IT organization. All reusable +workflows are located in the directory [.github/workflows](.github/workflows). + +* [lint](.github/workflows/lint.yml) +* [test](.github/workflows/test.yml) +* [release](.github/workflows/release.yml) + +Any workflow file that is not prefixed with `local-` is intended to be a reusable +workflow. The `local-` workflow files are the workflows in use by _this_ project, +themselves using the provided reusable workflows. The `local-` workflows may also +be considered examples of how the reusable workflows are expected to be invoked. + +## Provided reusable workflows + +### `lint` + +An example of calling the reusable `lint` workflow: + +``` +name: Run lint and static analyis checks +on: + pull_request: + +# Cancel other lint workflows when source is updated +concurrency: + group: lint-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + lint: + uses: plus3it/actions-workflows/.github/workflows/lint.yml@v1 +``` + +### `test` + +An example of calling the reusable `test` workflow: + +``` +name: Run test jobs +on: + pull_request: + +# Cancel other test workflows when source is updated +concurrency: + group: test-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + test: + uses: plus3it/actions-workflows/.github/workflows/test.yml@v1 +``` + +### `release` + +An example of calling the reusable `release` workflow: + +``` +name: Create GitHub Release + +on: + # Run on demand + workflow_dispatch: + + # Run on push to main when .bumpversion.cfg version is updated + push: + branches: + - main + paths: + - .bumpversion.cfg + +jobs: + release: + uses: plus3it/actions-workflows/.github/workflows/release.yml@v1 + secrets: + release-token: ${{ secrets.GH_RELEASES_TOKEN }} +``` From 87fc73eaf4e424e3fa1819e92af66b5b134fe727 Mon Sep 17 00:00:00 2001 From: Loren Gordon Date: Tue, 24 Jan 2023 06:38:58 -0800 Subject: [PATCH 2/3] Adds input to enable/disable mockstacktest job --- .github/workflows/release.yml | 8 ++++++++ .github/workflows/test.yml | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 52d3466..d00d832 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,6 +3,12 @@ name: Create GitHub Release on: # Run as a reusable workflow workflow_call: + inputs: + mockstacktest-enable: + description: Controls whether to run the mockstacktest job + default: true + required: false + type: boolean secrets: release-token: description: Token with permissions to create GitHub Releases @@ -14,6 +20,8 @@ jobs: test: uses: ./.github/workflows/test.yml + with: + mockstacktest-enable: ${{ inputs.mockstacktest-enable }} release: needs: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fff8758..08f6cb3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,9 +1,16 @@ name: Run test jobs on: workflow_call: + inputs: + mockstacktest-enable: + description: Controls whether to run the mockstacktest job + default: true + required: false + type: boolean jobs: mockstacktest: + if: inputs.mockstacktest-enable runs-on: ubuntu-latest steps: - name: Clone this git repository From 8cd0662217dbe3ba17ce9d258f6a03fd672f7c5e Mon Sep 17 00:00:00 2001 From: Loren Gordon Date: Tue, 24 Jan 2023 06:51:59 -0800 Subject: [PATCH 3/3] Documents inputs for reusable workflows in readme --- .github/workflows/lint.yml | 2 +- README.md | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9f138e5..e48270b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,7 +3,7 @@ on: workflow_call: inputs: tardigradelint-target: - description: Name of the Tardigrade-CI target to run + description: Name of the Tardigrade-CI Makefile target to run default: lint required: false type: string diff --git a/README.md b/README.md index aab1dec..6220651 100644 --- a/README.md +++ b/README.md @@ -8,15 +8,20 @@ workflows are located in the directory [.github/workflows](.github/workflows). * [test](.github/workflows/test.yml) * [release](.github/workflows/release.yml) -Any workflow file that is not prefixed with `local-` is intended to be a reusable +Any workflow file that is not prefixed with `local-` is provided as a reusable workflow. The `local-` workflow files are the workflows in use by _this_ project, -themselves using the provided reusable workflows. The `local-` workflows may also -be considered examples of how the reusable workflows are expected to be invoked. +themselves using the reusable workflows. The `local-` workflows are also examples +of how the reusable workflows are expected to be invoked. -## Provided reusable workflows +## Reusable workflows ### `lint` +Inputs: + +* `tardigradelint-target`: Controls which tardigrade-ci Makefile target to run. + Defaults to `lint`. + An example of calling the reusable `lint` workflow: ``` @@ -36,6 +41,11 @@ jobs: ### `test` +Inputs: + +* `mockstacktest-enable`: Controls whether to run the mockstacktest job. Defaults + to `true`. + An example of calling the reusable `test` workflow: ``` @@ -55,6 +65,14 @@ jobs: ### `release` +Inputs: + +* `mockstacktest-enable`: Controls whether to run the mockstacktest job. Defaults + to `true`. + +Secrets: + * `release-token`: Required. Token with permissions to create GitHub Releases. + An example of calling the reusable `release` workflow: ```