Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds inputs for lint/release and reuses workflows locally #2

Merged
merged 3 commits into from
Jan 24, 2023
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
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 }}
```