Skip to content

Commit 48e3c7f

Browse files
committed
[#74] Moved CI to GHA and publishing from GHA.
1 parent 3046c88 commit 48e3c7f

6 files changed

Lines changed: 233 additions & 104 deletions

File tree

.circleci/config.yml

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

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Ignore files for distribution archives.
22

3-
/.circleci export-ignore
43
/.editorconfig export-ignore
54
/.gitattributes export-ignore
65
/.github export-ignore

.github/workflows/release.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
branches:
8+
- main
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
release-drafter:
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Generate CalVer version
23+
id: calver
24+
run: |
25+
export VERSION="$(date "+%y.%-m").0"
26+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
27+
echo "Version set to ${VERSION}"
28+
29+
- name: Draft release notes
30+
uses: release-drafter/release-drafter@b1476f6e6eb133afa41ed8589daba6dc69b4d3f5 # v6
31+
with:
32+
tag: ${{ steps.calver.outputs.version }}
33+
name: ${{ steps.calver.outputs.version }}
34+
version: ${{ steps.calver.outputs.version }}
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
38+
push-release-to-registry:
39+
if: startsWith(github.ref, 'refs/tags/')
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
- name: Checkout code
44+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
45+
46+
- name: Set up QEMU
47+
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3
48+
49+
- name: Set up Docker Buildx
50+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3
51+
52+
- name: Log in to Docker Hub
53+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3
54+
with:
55+
username: ${{ secrets.DOCKER_USER }}
56+
password: ${{ secrets.DOCKER_PASS }}
57+
58+
- name: Extract metadata (tags, labels) for Docker
59+
id: meta
60+
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5
61+
with:
62+
images: drevops/mariadb-drupal-data
63+
64+
- name: Build and push Docker image
65+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6
66+
with:
67+
context: .
68+
push: true
69+
tags: ${{ steps.meta.outputs.tags }}
70+
labels: ${{ steps.meta.outputs.labels }}
71+
platforms: linux/amd64,linux/arm64

.github/workflows/test.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- 'feature/**'
8+
push:
9+
branches:
10+
- main
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
16+
container:
17+
# https://hub.docker.com/r/drevops/ci-runner
18+
image: drevops/ci-runner:25.9.0@sha256:94e278c994808d966dd28143fe990b19351697a5915a0ab346f39434aec28b27
19+
20+
steps:
21+
- name: Configure Git safe directory
22+
run: git config --global --add safe.directory "${GITHUB_WORKSPACE}"
23+
24+
- name: Check out the repo
25+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
26+
27+
- name: Lint shell scripts
28+
run: |
29+
shfmt -i 2 -ci -s -d seed.sh tests/bats/*.bash tests/bats/*.bats
30+
shellcheck seed.sh tests/bats/*.bash tests/bats/*.bats
31+
continue-on-error: ${{ vars.CI_LINT_IGNORE_FAILURE == '1' }}
32+
33+
- name: Install goss
34+
run: curl -fsSL https://goss.rocks/install | sh && goss --version
35+
36+
- name: Build Docker image
37+
run: docker build -t gosstestorg/gosstestimage:goss-test-tag .
38+
39+
- name: Run Goss tests
40+
run: |
41+
export GOSS_FILES_STRATEGY=cp
42+
export GOSS_PATH=/usr/local/bin/goss
43+
GOSS_FILES_PATH=tests/dgoss dgoss run -i gosstestorg/gosstestimage:goss-test-tag
44+
continue-on-error: ${{ vars.CI_TEST_IGNORE_FAILURE == '1' }}
45+
46+
- name: Install BATS dependencies
47+
run: npm --prefix tests/bats ci
48+
49+
- name: Run BATS tests with code coverage
50+
run: |
51+
echo "${DOCKER_PASS}" | docker login --username "${DOCKER_USER}" --password-stdin
52+
kcov --include-pattern=.sh,.bash --bash-parse-files-in-dir=. --exclude-pattern=vendor,node_modules,coverage $(pwd)/coverage tests/bats/node_modules/.bin/bats tests/bats
53+
shell: bash
54+
continue-on-error: ${{ vars.CI_TEST_IGNORE_FAILURE == '1' }}
55+
env:
56+
DOCKER_USER: ${{ secrets.DOCKER_USER }}
57+
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
58+
59+
- name: Upload coverage report as an artifact
60+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
61+
with:
62+
name: ${{github.job}}-code-coverage-report
63+
include-hidden-files: true
64+
path: coverage
65+
if-no-files-found: error
66+
67+
- name: Upload coverage report to Codecov
68+
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5
69+
if: ${{ env.CODECOV_TOKEN != '' }}
70+
with:
71+
directory: coverage
72+
fail_ci_if_error: true
73+
token: ${{ secrets.CODECOV_TOKEN }}
74+
env:
75+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
76+
77+
push-canary-to-registry:
78+
if: github.event_name == 'push'
79+
runs-on: ubuntu-latest
80+
81+
needs:
82+
- test
83+
84+
steps:
85+
- name: Checkout code
86+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
87+
88+
- name: Set up QEMU
89+
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3
90+
91+
- name: Set up Docker Buildx
92+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3
93+
94+
- name: Log in to Docker Hub
95+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3
96+
with:
97+
username: ${{ secrets.DOCKER_USER }}
98+
password: ${{ secrets.DOCKER_PASS }}
99+
100+
- name: Extract metadata (tags, labels) for Docker
101+
id: meta
102+
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5
103+
with:
104+
images: drevops/mariadb-drupal-data
105+
106+
- name: Build and push Docker image
107+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6
108+
with:
109+
context: .
110+
push: true
111+
tags: drevops/mariadb-drupal-data:canary
112+
labels: ${{ steps.meta.outputs.labels }}
113+
platforms: linux/amd64,linux/arm64

CLAUDE.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,25 @@ BUILDX_PLATFORMS=linux/arm64 DOCKER_DEFAULT_PLATFORM=linux/arm64 tests/bats/node
9898

9999
## CI/CD
100100

101-
- Uses CircleCI with `drevops/ci-runner:25.9.0` image
102-
- Publishes to DockerHub:
103-
- `main` branch → `canary` tag
104-
- Git tags → versioned tag + `latest`
105-
- Feature branches → `feature-branch-name` tag (but renovate branches are skipped)
101+
### Workflows
102+
103+
**test.yml** - Runs on PRs and pushes to main:
104+
- Uses `drevops/ci-runner:25.9.0` container image
105+
- Lints shell scripts with `shfmt` and `shellcheck`
106+
- Runs Goss structural tests
107+
- Runs BATS tests with code coverage (kcov)
108+
- Uploads coverage to Codecov
109+
- Pushes `canary` tag to DockerHub on main branch
110+
111+
**release.yml** - Runs on Git tags:
112+
- Drafts release notes using release-drafter
113+
- Builds and pushes versioned + `latest` tags to DockerHub
114+
115+
### Configuration
116+
106117
- Multi-platform builds: `linux/amd64,linux/arm64`
107-
- Code coverage uploaded to Codecov via kcov
118+
- Required secrets: `DOCKER_USER`, `DOCKER_PASS`, `CODECOV_TOKEN`
119+
- Optional vars: `CI_LINT_IGNORE_FAILURE`, `CI_TEST_IGNORE_FAILURE` (set to '1' to ignore failures)
108120

109121
## Important Notes
110122

README.md

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
[![GitHub Issues](https://img.shields.io/github/issues/drevops/mariadb-drupal-data.svg)](https://github.com/drevops/mariadb-drupal-data/issues)
1111
[![GitHub Pull Requests](https://img.shields.io/github/issues-pr/drevops/mariadb-drupal-data.svg)](https://github.com/drevops/mariadb-drupal-data/pulls)
12-
[![CircleCI](https://circleci.com/gh/drevops/mariadb-drupal-data.svg?style=shield)](https://circleci.com/gh/drevops/mariadb-drupal-data)
12+
[![Test and Build](https://github.com/drevops/mariadb-drupal-data/actions/workflows/test.yml/badge.svg)](https://github.com/drevops/mariadb-drupal-data/actions/workflows/test.yml)
1313
[![codecov](https://codecov.io/gh/drevops/mariadb-drupal-data/graph/badge.svg?token=JYSIXUF6QX)](https://codecov.io/gh/drevops/mariadb-drupal-data)
1414
![GitHub release (latest by date)](https://img.shields.io/github/v/release/drevops/mariadb-drupal-data)
1515
![LICENSE](https://img.shields.io/github/license/drevops/mariadb-drupal-data)
@@ -75,21 +75,43 @@ BASE_IMAGE=drevops/mariadb-drupal-data:canary ./seed.sh path/to/db.sql myorg/myi
7575

7676
Note that you should already be logged in to the registry as `seed.sh` will be pushing an image as a part of `docker buildx` process.
7777

78-
## Maintenance
78+
## Maintenance and releasing
7979

8080
### Running tests
8181

82-
tests/bats/node_modules/.bin/bats tests/bats/image.bats --tap
83-
tests/bats/node_modules/.bin/bats tests/bats/seed.bats --tap
82+
```shell
83+
npm --prefix tests/bats install
84+
tests/bats/node_modules/.bin/bats tests/bats/image.bats --tap
85+
tests/bats/node_modules/.bin/bats tests/bats/seed.bats --tap
86+
```
87+
88+
### Versioning
8489

85-
### Publishing
90+
This project uses _Year-Month-Patch_ versioning:
8691

87-
This image is built and pushed automatically to DockerHub:
88-
1. For all commits to `main` branch as `canary` tag.
89-
2. For releases as `:<version>` and `latest` tag.
90-
3. For `feature/my-branch` branches as `feature-my-branch` tag.
92+
- `YY`: Last two digits of the year, e.g., `23` for 2023.
93+
- `m`: Numeric month, e.g., April is `4`.
94+
- `patch`: Patch number for the month, starting at `0`.
95+
96+
Example: `23.4.2` indicates the third patch in April 2023.
9197

9298
Versions are following versions of the [upstream image](https://hub.docker.com/r/uselagoon/mariadb-drupal/tags) to ease maintenance.
9399

100+
### Releasing
101+
102+
Releases are scheduled to occur at a minimum of once per month.
103+
104+
This image is built by DockerHub via an automated build and tagged as follows:
105+
106+
- `YY.m.patch` tag - when release tag is published on GitHub.
107+
- `latest` - when release tag is published on GitHub.
108+
- `canary` - on every push to `main` branch
109+
110+
### Dependencies update
111+
112+
Renovate bot is used to update dependencies. It creates a PR with the changes
113+
and automatically merges it if CI passes. These changes are then released as
114+
a `canary` version.
115+
94116
---
95117
_This repository was created using the [Scaffold](https://getscaffold.dev/) project template_

0 commit comments

Comments
 (0)