Skip to content

Commit 0112e6d

Browse files
authored
feat(ci): Implement mechanism to release new versions of ETL (#316)
1 parent 2a41356 commit 0112e6d

File tree

9 files changed

+333
-68
lines changed

9 files changed

+333
-68
lines changed

.github/workflows/audit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ jobs:
1616
security_audit:
1717
runs-on: ubuntu-latest
1818
steps:
19-
- name: Checkout repository
19+
- name: Checkout
2020
uses: actions/checkout@v4
2121

2222
- name: Install cargo-deny
2323
uses: taiki-e/install-action@cargo-deny
2424

25-
- name: Scan for vulnerabilities
25+
- name: Scan for Vulnerabilities
2626
run: cargo deny check advisories

.github/workflows/ci.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,35 @@ permissions:
1515

1616
jobs:
1717
check:
18-
name: Check
18+
name: Lint
1919
runs-on: ubuntu-latest
2020
strategy:
2121
matrix:
2222
check: [fmt, clippy]
2323
steps:
24-
- name: Checkout repository
24+
- name: Checkout
2525
uses: actions/checkout@v4
2626

27-
- name: Install Rust toolchain
27+
- name: Set up Rust
2828
uses: dtolnay/rust-toolchain@stable
2929
with:
3030
components: ${{ matrix.check == 'fmt' && 'rustfmt' || 'clippy' }}
3131

32-
- name: Setup Rust cache
32+
- name: Cache Cargo
3333
uses: Swatinem/rust-cache@v2
3434
with:
3535
key: ${{ matrix.check }}
3636

37-
- name: Run cargo fmt
37+
- name: Run Cargo Fmt
3838
if: matrix.check == 'fmt'
3939
run: cargo fmt --check
4040

41-
- name: Run cargo clippy
41+
- name: Run Cargo Clippy
4242
if: matrix.check == 'clippy'
4343
run: cargo clippy --all-targets --all-features --no-deps -- -D warnings
4444

4545
test-partial:
46-
name: Test Partial
46+
name: Tests (Partial)
4747
runs-on: ubuntu-latest
4848
# Run on forks.
4949
if: github.event.pull_request.head.repo.fork == true
@@ -53,18 +53,18 @@ jobs:
5353
matrix:
5454
postgres_version: [17, 16, 15, 14]
5555
steps:
56-
- name: Checkout repository
56+
- name: Checkout
5757
uses: actions/checkout@v4
5858

59-
- name: Install Rust toolchain
59+
- name: Set up Rust
6060
uses: dtolnay/rust-toolchain@stable
6161

62-
- name: Setup Rust cache
62+
- name: Cache Cargo
6363
uses: Swatinem/rust-cache@v2
6464
with:
6565
key: test-partial
6666

67-
- name: Start Docker Compose Environment (Postgres ${{ matrix.postgres_version }})
67+
- name: Start Docker Compose (Postgres ${{ matrix.postgres_version }})
6868
run: |
6969
POSTGRES_VERSION=${{ matrix.postgres_version }} docker compose -f ./scripts/docker-compose.yaml up -d
7070
@@ -75,7 +75,7 @@ jobs:
7575
--no-default-features \
7676
--locked
7777
78-
- name: Migrate database
78+
- name: Migrate Database
7979
env:
8080
POSTGRES_USER: postgres
8181
POSTGRES_PASSWORD: postgres
@@ -86,7 +86,7 @@ jobs:
8686
sudo apt-get install libpq-dev -y
8787
./etl-api/scripts/run_migrations.sh
8888
89-
- name: Run tests
89+
- name: Run Tests
9090
run: |
9191
cargo test \
9292
--workspace \
@@ -101,7 +101,7 @@ jobs:
101101
--features iceberg
102102
103103
test-full:
104-
name: Test Full
104+
name: Tests (Full)
105105
runs-on: ubuntu-latest
106106
# Run on non-forks.
107107
if: github.event.pull_request.head.repo.fork == false
@@ -112,18 +112,18 @@ jobs:
112112
matrix:
113113
postgres_version: [17, 16, 15, 14]
114114
steps:
115-
- name: Checkout repository
115+
- name: Checkout
116116
uses: actions/checkout@v4
117117

118-
- name: Install Rust toolchain
118+
- name: Set up Rust
119119
uses: dtolnay/rust-toolchain@stable
120120

121-
- name: Setup Rust cache
121+
- name: Cache Cargo
122122
uses: Swatinem/rust-cache@v2
123123
with:
124124
key: test-full
125125

126-
- name: Start Docker Compose Environment (Postgres ${{ matrix.postgres_version }})
126+
- name: Start Docker Compose (Postgres ${{ matrix.postgres_version }})
127127
run: |
128128
POSTGRES_VERSION=${{ matrix.postgres_version }} docker compose -f ./scripts/docker-compose.yaml up -d
129129
@@ -134,7 +134,7 @@ jobs:
134134
--no-default-features \
135135
--locked
136136
137-
- name: Migrate database
137+
- name: Migrate Database
138138
env:
139139
POSTGRES_USER: postgres
140140
POSTGRES_PASSWORD: postgres
@@ -148,21 +148,21 @@ jobs:
148148
- name: Install cargo-llvm-cov
149149
uses: taiki-e/install-action@cargo-llvm-cov
150150

151-
- name: Set up BigQuery environment variables and credentials
151+
- name: Set up BigQuery Credentials
152152
run: |
153153
printf '%s' '${{ secrets.TESTS_BIGQUERY_SA_KEY_JSON }}' > /tmp/bigquery-sa-key.json
154154
echo "TESTS_BIGQUERY_PROJECT_ID=${{ secrets.TESTS_BIGQUERY_PROJECT_ID }}" >> $GITHUB_ENV
155155
echo "TESTS_BIGQUERY_SA_KEY_PATH=/tmp/bigquery-sa-key.json" >> $GITHUB_ENV
156156
157-
- name: Generate code coverage
157+
- name: Generate Code Coverage
158158
id: coverage
159159
run: |
160160
cargo llvm-cov test \
161161
--workspace --no-fail-fast \
162162
--all-features \
163163
--lcov --output-path lcov.info
164164
165-
- name: Upload coverage to Coveralls
165+
- name: Upload Coverage to Coveralls
166166
uses: coverallsapp/github-action@v2
167167
with:
168168
fail-on-error: false

.github/workflows/docker-build.yml

Lines changed: 57 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,80 @@
11
name: Docker Build
22

33
on:
4-
push:
5-
branches: [main]
6-
workflow_dispatch:
7-
8-
env:
9-
CARGO_TERM_COLOR: always
4+
workflow_call:
5+
inputs:
6+
image:
7+
description: "Docker image (e.g. docker.io/<org>/<repo>)"
8+
type: string
9+
required: true
10+
context:
11+
description: "Docker build context"
12+
type: string
13+
default: "."
14+
push:
15+
description: "Push image to registry"
16+
type: boolean
17+
default: false
18+
tag_with_version:
19+
description: "Also tag the image with version"
20+
type: boolean
21+
default: false
22+
version:
23+
description: "Version to tag when tag_with_version=true"
24+
type: string
25+
required: false
1026

1127
permissions:
1228
contents: read
1329

1430
jobs:
1531
docker:
16-
name: Build and Push Docker Images
32+
name: Build Docker Image
1733
runs-on: ubuntu-latest
18-
strategy:
19-
matrix:
20-
image: [etl-api, etl-replicator]
2134
steps:
22-
- name: Checkout repository
35+
- name: Checkout
2336
uses: actions/checkout@v4
2437

2538
- name: Set up Docker Buildx
2639
uses: docker/setup-buildx-action@v3
2740

28-
- name: Login to Docker Hub
41+
- name: Log in to Docker Hub
42+
if: inputs.push == true
2943
uses: docker/login-action@v3
3044
with:
3145
username: ${{ vars.DOCKERHUB_USERNAME }}
3246
password: ${{ secrets.DOCKERHUB_TOKEN }}
3347

34-
- name: Build and push ${{ matrix.image }} image
35-
uses: docker/build-push-action@v6
36-
id: build
48+
- name: Docker Metadata
49+
id: meta
50+
uses: docker/metadata-action@v5
3751
with:
38-
file: ./${{ matrix.image }}/Dockerfile
39-
push: true
40-
cache-from: type=gha,scope=${{ matrix.image }}
41-
cache-to: type=gha,mode=max,scope=${{ matrix.image }}
52+
images: ${{ inputs.image }}
4253
tags: |
43-
${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.image }}:latest
44-
${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.image }}:${{ github.ref_name }}
45-
${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.image }}:${{ github.sha }}
46-
47-
- name: Output image information
48-
run: |
49-
echo "✅ Successfully built and pushed ${{ matrix.image }} image"
50-
echo "🏷️ Tags: latest, ${{ github.ref_name }}, ${{ github.sha }}"
51-
echo "🔗 View at: https://hub.docker.com/r/${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.image }}"
54+
type=raw,value=latest
55+
type=sha,format=short,prefix=
56+
${{ inputs.tag_with_version && format('type=raw,value=v{0}', inputs.version) || '' }}
57+
58+
- name: Build and Push Image
59+
id: build
60+
uses: docker/build-push-action@v5
61+
with:
62+
context: ${{ inputs.context }}
63+
push: ${{ inputs.push }}
64+
tags: ${{ steps.meta.outputs.tags }}
65+
cache-from: type=gha
66+
cache-to: type=gha,mode=max
67+
68+
- name: Output Image Information
69+
run: |
70+
IMAGE="${{ inputs.image }}"
71+
NAME="${IMAGE##*/}"
72+
SHORT_SHA="${GITHUB_SHA::7}"
73+
TAGS="latest, ${SHORT_SHA}"
74+
if [ "${{ inputs.tag_with_version }}" = "true" ] && [ -n "${{ inputs.version }}" ]; then
75+
TAGS="${TAGS}, v${{ inputs.version }}"
76+
fi
77+
HUB_PATH=$(echo "${IMAGE}" | sed -E 's@^docker\.io/@@')
78+
echo "✅ Successfully built and pushed ${NAME} image"
79+
echo "🏷️ Tags: ${TAGS}"
80+
echo "🔗 View at: https://hub.docker.com/r/${HUB_PATH}"

.github/workflows/docker-ci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Docker CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
build:
13+
name: Build and Push Images
14+
strategy:
15+
matrix:
16+
image: [etl-api, etl-replicator]
17+
uses: ./.github/workflows/docker-build.yml
18+
secrets: inherit
19+
with:
20+
image: docker.io/${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.image }}
21+
context: ./${{ matrix.image }}
22+
push: true
23+
tag_with_version: false

.github/workflows/docs.yml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
name: Docs
22

3+
concurrency:
4+
group: docs
5+
cancel-in-progress: false
6+
37
on:
48
push:
59
branches: [main]
610
pull_request:
711
branches: [main]
812

9-
concurrency:
10-
group: docs
11-
cancel-in-progress: false
12-
1313
permissions:
1414
contents: write
1515

@@ -18,38 +18,50 @@ jobs:
1818
runs-on: ubuntu-latest
1919
if: github.event_name == 'push'
2020
steps:
21-
- uses: actions/checkout@v4
21+
- name: Checkout
22+
uses: actions/checkout@v4
2223
- name: Configure Git Credentials
2324
run: |
2425
git config user.name github-actions[bot]
2526
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
26-
- uses: actions/setup-python@v5
27+
- name: Set up Python
28+
uses: actions/setup-python@v5
2729
with:
2830
python-version: 3.x
29-
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
30-
- uses: actions/cache@v4
31+
- name: Compute Cache Key
32+
run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
33+
- name: Restore Docs Cache
34+
uses: actions/cache@v4
3135
with:
3236
key: mkdocs-material-${{ env.cache_id }}
3337
path: ~/.cache
3438
restore-keys: |
3539
mkdocs-material-
36-
- run: pip install -r docs/requirements_docs.txt
37-
- run: mkdocs gh-deploy --force
40+
- name: Install Docs Requirements
41+
run: pip install -r docs/requirements_docs.txt
42+
- name: Deploy Docs
43+
run: mkdocs gh-deploy --force
3844

3945
build:
4046
runs-on: ubuntu-latest
4147
if: github.event_name == 'pull_request'
4248
steps:
43-
- uses: actions/checkout@v4
44-
- uses: actions/setup-python@v5
49+
- name: Checkout
50+
uses: actions/checkout@v4
51+
- name: Set up Python
52+
uses: actions/setup-python@v5
4553
with:
4654
python-version: 3.x
47-
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
48-
- uses: actions/cache@v4
55+
- name: Compute Cache Key
56+
run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
57+
- name: Restore Docs Cache
58+
uses: actions/cache@v4
4959
with:
5060
key: mkdocs-material-${{ env.cache_id }}
5161
path: ~/.cache
5262
restore-keys: |
5363
mkdocs-material-
54-
- run: pip install -r docs/requirements_docs.txt
55-
- run: mkdocs build --strict
64+
- name: Install Docs Requirements
65+
run: pip install -r docs/requirements_docs.txt
66+
- name: Build Docs
67+
run: mkdocs build --strict

0 commit comments

Comments
 (0)