Skip to content

Commit

Permalink
Merge pull request #2 from lorengordon/inputs
Browse files Browse the repository at this point in the history
Adds inputs for lint/release and reuses workflows locally
  • Loading branch information
johnricords authored Jan 24, 2023
2 parents 657f8a9 + 8cd0662 commit 4105630
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 22 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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 Makefile target to run
default: lint
required: false
type: string

jobs:
tardigradelint:
Expand All @@ -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
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/local-lint.yml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions .github/workflows/local-release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
11 changes: 11 additions & 0 deletions .github/workflows/local-test.yml
Original file line number Diff line number Diff line change
@@ -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
25 changes: 15 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
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:
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
required: true

jobs:
lint:
uses: ./.github/workflows/lint.yml

test:
uses: ./.github/workflows/test.yml
with:
mockstacktest-enable: ${{ inputs.mockstacktest-enable }}

release:
needs:
Expand Down Expand Up @@ -51,4 +56,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 }}
12 changes: 7 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
name: Run test jobs
on:
pull_request:
workflow_call:

concurrency:
group: test-${{ github.head_ref || github.ref }}
cancel-in-progress: true
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
Expand Down
97 changes: 96 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,97 @@
# 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 provided as a reusable
workflow. The `local-` workflow files are the workflows in use by _this_ project,
themselves using the reusable workflows. The `local-` workflows are also examples
of how the reusable workflows are expected to be invoked.

## 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:

```
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`

Inputs:

* `mockstacktest-enable`: Controls whether to run the mockstacktest job. Defaults
to `true`.

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`

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:

```
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 }}
```

0 comments on commit 4105630

Please sign in to comment.