Skip to content

Commit d191189

Browse files
committed
chore(ci): Use make targets in CI for consistency
1 parent eefe910 commit d191189

File tree

14 files changed

+229
-79
lines changed

14 files changed

+229
-79
lines changed

.github/hooks/commit-msg

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
# Allows for standard conventional commits OR git's auto-squash prefixes.
4+
commit_regex="^((fixup|squash|amend)!|(feat|fix|docs|style|refactor|perf|test|chore)!?(\(.+\))?:) .+$"
5+
6+
if ! grep -iqE "$commit_regex" "$1"; then
7+
echo "Aborting commit." >&2
8+
echo "Commit messages should follow the conventional commit format or use a git autosquash prefix." >&2
9+
echo "" >&2
10+
echo "Conventional format: 'type(scope): message'" >&2
11+
echo "Allowed types: feat, fix, docs, style, refactor, perf, test, chore" >&2
12+
echo "See https://www.conventionalcommits.org/en/v1.0.0/#summary" >&2
13+
echo "" >&2
14+
echo "Autosquash prefixes: 'fixup!', 'squash!', 'amend!'" >&2
15+
echo "Example: 'fixup! feat(user): add new login button'" >&2
16+
exit 1
17+
fi

.github/hooks/pre-push

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
echo "Running pre-push checks..."
4+
5+
# Ensure in repo root
6+
REPO_ROOT=$(git rev-parse --show-toplevel)
7+
cd "$REPO_ROOT" || exit 1
8+
9+
echo " * Checking linting..."
10+
# Run linting checks (exit code 0 indicates nothing to fix)
11+
make lint.dryrun &> /dev/null
12+
if [ ! $? -eq 0 ]; then
13+
make lint &> /dev/null
14+
echo "ERROR: Linting/typechecking failed. Files may have been reformatted."
15+
echo " Please stage and commit these changes before pushing, and ensure typesafety."
16+
echo " (hint: 'git commit -am \"chore(repo): Code formatting\"')"
17+
exit 1
18+
fi
19+

.github/pull-request-template.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
### Contribution Checklist
2+
3+
- [ ] Have you followed the Open Climate Fix [Contribution Guidelines](https://github.com/openclimatefix#github-contributions)?
4+
- [ ] Have you referenced the [Issue](https://github.com/openclimatefix/satellite-consumer/issues) this PR addresses, where applicable?
5+
- [ ] Have you checked to ensure there aren't other open [Pull Requests](https://github.com/openclimatefix/satellite-consumer/pulls) for the same change?
6+
- [ ] Have you added a summary of the changes?
7+
- [ ] Have you written new tests for your changes, where applicable?
8+
- [ ] Have you successfully run `make lint` with your changes locally?
9+
- [ ] Have you successfully run `make test` with your changes locally?
10+
11+
> [!Warning]
12+
> PRs may be closed if all the above boxes are not checked.
13+
14+
15+
### Changes in this Pull Request
16+

.github/workflows/branch_ci.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Build Containers
2+
3+
on:
4+
push:
5+
branches-ignore: ['main']
6+
paths-ignore: ['README.md', '.github/workflows/test.yml']
7+
tags: ['v*.*.*']
8+
9+
env:
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: ${{ github.repository }}
12+
13+
jobs:
14+
build-container:
15+
if: github.event_name != 'pull_request'
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24+
25+
- name: Log in to the Container registry
26+
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
27+
with:
28+
registry: ghcr.io
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Set up Buildx
33+
id: setup-buildx
34+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
35+
36+
- name: Extract metadata (tags, labels) for Container
37+
id: meta
38+
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
39+
with:
40+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41+
tags: |
42+
type=ref,event=branch
43+
type=semver,pattern={{version}}
44+
45+
- name: Build and push Docker images
46+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # 6.18.0
47+
with:
48+
context: .
49+
file: Dockerfile
50+
platforms: linux/amd64
51+
push: ${{ github.event_name != 'pull_request' }}
52+
tags: ${{ steps.meta.outputs.tags }}
53+
labels: ${{ steps.meta.outputs.labels }}
54+
cache-from: type=gha
55+
cache-to: type=gha,mode=max
56+
env:
57+
DOCKER_BUILD_RECORD_RETENTION_DAYS: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && '0' || '7' }}
58+

.github/workflows/merged_ci.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/tag.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Bump Tag
2+
3+
on:
4+
pull_request:
5+
types: ["closed"]
6+
branches: ["main"]
7+
8+
jobs:
9+
10+
# Define an autotagger job that creates tags on changes to master
11+
bump-tag:
12+
runs-on: ubuntu-latest
13+
if: github.event.pull_request.merged == true
14+
permissions:
15+
contents: write
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
20+
with:
21+
ref: ${{ github.event.pull_request.merge_commit_sha }}
22+
fetch-depth: 0
23+
token: ${{ secrets.OCF_BOT_PAT_TOKEN }}
24+
25+
# Bump tag according to conventional commit rules
26+
# See https://www.conventionalcommits.org/en/v1.0.0
27+
- name: Bump version and push tag
28+
uses: anothrNick/github-tag-action@a2c70ae13a881faf2b4953baaa9e49731997ab36 # v1.67.0
29+
id: tag
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.OCF_BOT_PAT_TOKEN }}
32+
RELEASE_BRANCHES: main
33+
WITH_V: true
34+
GIT_API_TAGGING: false
35+
MAJOR_STRING_TOKEN: "BREAKING CHANGE"
36+
MINOR_STRING_TOKEN: "feat("
37+
PATCH_STRING_TOKEN: "fix("
38+
DEFAULT_BUMP: none

.github/workflows/tagged_ci.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Unit Test
2+
3+
on:
4+
push:
5+
branches-ignore: [ "main" ]
6+
paths-ignore: ['README.md']
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
15+
16+
- name: Set up UV
17+
uses: astral-sh/setup-uv@e92bafb6253dcd438e0484186d7669ea7a8ca1cc # v6.4.3
18+
with:
19+
enable-cache: true
20+
21+
- name: Check linting / typechecking / formatting
22+
run: make lint.dryrun
23+
24+
- name: Run unit tests
25+
run: make test
26+
27+
- name: Test Summary
28+
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4
29+
with:
30+
paths: "unit-tests.xml"
31+
output: "test-summary.md"
32+
if: always()
33+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ htmlcov/
5050
.cache
5151
nosetests.xml
5252
coverage.xml
53+
unit-tests.xml
5354
*.cover
5455
*.py,cover
5556
.hypothesis/

0 commit comments

Comments
 (0)