Skip to content

Commit

Permalink
feat(dags-container): upgrade ci to use build caching and merge base …
Browse files Browse the repository at this point in the history
…and dags container
  • Loading branch information
JossWhittle committed Apr 8, 2024
1 parent fa3e7ee commit 476b10c
Show file tree
Hide file tree
Showing 15 changed files with 206 additions and 204 deletions.
8 changes: 8 additions & 0 deletions .github/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[flake8]
per-file-ignores =
# imported but unused
__init__.py: F401

max-complexity = 10

extend-ignore = E501,C901
15 changes: 15 additions & 0 deletions .github/commitlint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { RuleConfigSeverity } from '@commitlint/types';

export default {
extends: ['@commitlint/config-conventional'],
parserPreset: 'conventional-changelog-conventionalcommits',
rules: {
'scope-enum': [RuleConfigSeverity.Error, 'always', [
'',
'deps',
'dags',
'dags-container'
]],
'subject-case': [RuleConfigSeverity.Error, 'never', []],
}
};
24 changes: 24 additions & 0 deletions .github/labeler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Release branches where trunk branches are merge-committed to trigger releases

release:
- base-branch:
- 'main'
- 'maintenance/.+/[0-9]+\.([0-9]+|x)\.x'

# Label any maintenance branch, trunk and release

maintenance:
- base-branch:
- 'maintenance/.+/[0-9]+\.([0-9]+|x)\.x'

# Label PRs into the main branch

main:
- base-branch:
- 'main'

# Labels for PRs on asset specific branches

dags-container:
- base-branch:
- '.+/dags-container(/.+)?'
14 changes: 14 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## :construction: Suggest a change

A clear and concise description of what you are changing.

## :memo: Pre-merge checklist

Ready to merge? Do not merge until all checks are satisfied.
- [ ] :chart: Have all `required` CI checks passed on the most recent commit?
- [ ] :black_nib: Is the PR title a valid and meaningful conventional-commit message? ie. `type(scope): summary`
- [ ] :boom: Are `breaking changes` declared in the PR title in conventional-commit style? ie. `type!(scope): summary`
- [ ] :art: Does new code follow the code style of this project?
- [ ] :mag: Has new code been spellchecked and linted?
- [ ] :book: Have docs been updated where necessary?
- [ ] :poop: Have commits been checked for accidental file inclusions?
63 changes: 63 additions & 0 deletions .github/workflows/dags-container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: DAGs Container

on:
pull_request:
# Ignore PRs on branches specifically intended for other assets
branches-ignore: []
# Only consider PRs that change files for this asset, including ci scripts
paths:
- '.github/workflows/dags-flake8.yaml'
- '.github/workflows/dags-container.yaml'
- 'containers/dags/**'
- 'dags/**'
# Make sure all workflows that are "required checks" for a given
# branch protection rule have the same paths: and branches-ignore:
# filters. Otherwise, you can end up in a deadlock waiting on a
# required check that will never be executed.
push:
# Only release off of release and maintenance branches for this asset
branches:
- 'maintenance/dags-container/[0-9]+.x.x'
- 'maintenance/dags-container/[0-9]+.[0-9]+.x'
- 'main'
# Only consider pushes that change files for this asset, including ci scripts
paths:
- '.github/workflows/dags-container.yaml'
- 'containers/dags/**'
- 'dags/**'

permissions:
contents: write
pull-requests: read
actions: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# Needed to generate releases safely
cancel-in-progress: false

jobs:
# Job name must be unique across repo to target
# branch protection rules "required checks" properly!
dags-container:
uses: SwanseaUniversityMedical/workflows/.github/workflows/pr-and-release-container.yaml@v1.6.0-containers
with:
job-name: dags-container
registry: ${{ vars.HARBOR_REGISTRY }}
registry-user: ${{ vars.HARBOR_USER }}
registry-repo: dare/airflow/dags
release-tag-format: 'dags-container-${version}'
release-branches: |
[
'maintenance/dags-container/[0-9]+\.([0-9]+|x)\.x',
'main'
]
cosign-public-key: ${{ vars.COSIGN_PUBLIC_KEY }}
slack-channel: ${{ vars.SLACK_CHANNEL }}
build-file: containers/dags/Dockerfile
build-context: .
secrets:
cosign-private-key: ${{ secrets.COSIGN_PRIVATE_KEY }}
cosign-password: ${{ secrets.COSIGN_PASSWORD }}
registry-token: ${{ secrets.HARBOR_TOKEN }}
slack-token: ${{ secrets.SLACK_TOKEN }}
41 changes: 41 additions & 0 deletions .github/workflows/dags-flake8.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: DAGs Flake8

on:
pull_request:
# Ignore PRs on branches specifically intended for other assets
branches-ignore: []
# Only consider PRs that change files for this asset, including ci scripts
paths:
- '.github/workflows/dags-flake8.yaml'
- '.github/workflows/dags-container.yaml'
- 'containers/dags/**'
- 'dags/**'
# Make sure all workflows that are "required checks" for a given
# branch protection rule have the same paths: and branches-ignore:
# filters. Otherwise, you can end up in a deadlock waiting on a
# required check that will never be executed.

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# This linting can be cancelled if there is a newer commit to lint
cancel-in-progress: true

jobs:
dags-flake8:
runs-on:
labels: [self-hosted, linux, x64]
group: light

steps:
- name: clone repo
uses: actions/checkout@v4

- name: install flake8
run: pip install flake8

- name: install flake8 annotations
uses: rbialon/flake8-annotations@v1

- name: run flake8
run: |
flake8 --config=".github/.flake8" dags
46 changes: 0 additions & 46 deletions .github/workflows/flake8.yaml

This file was deleted.

74 changes: 0 additions & 74 deletions .github/workflows/on-pr-update.yaml

This file was deleted.

75 changes: 0 additions & 75 deletions .github/workflows/on-release.yaml

This file was deleted.

17 changes: 17 additions & 0 deletions .github/workflows/pr-labeler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Label PR

on:
pull_request:
# Run on all PRs whenever they are opened
types:
- opened
- reopened

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# This labelling can be cancelled if there is a newer run
cancel-in-progress: true

jobs:
pr-labeler:
uses: SwanseaUniversityMedical/workflows/.github/workflows/pr-labeler.yaml@v1.0.0-pr-labeler
Loading

0 comments on commit 476b10c

Please sign in to comment.