This repository was archived by the owner on Apr 27, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (116 loc) · 3.47 KB
/
Copy pathci.yml
File metadata and controls
136 lines (116 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: CI Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
defaults:
run:
shell: bash --noprofile --norc -eo pipefail {0}
jobs:
# Linting job using Docker Bake
lint:
name: Lint
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers - Lint
uses: actions/cache@v4
with:
path: .cache/lint
key: ${{ runner.os }}-docker-cache-lint-${{ hashFiles('**/Dockerfile', '**/docker-bake.hcl', 'go.mod', 'go.sum') }}
restore-keys: |
${{ runner.os }}-docker-cache-lint-
${{ runner.os }}-docker-cache-
- name: Run linting with Docker Bake
run: |
set -euo pipefail
docker buildx bake \
--set "*.cache-from=type=local,src=.cache/lint" \
--set "*.cache-to=type=local,dest=.cache/lint" \
lint
# Testing job using Docker Bake
test:
name: Test
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers - Test
uses: actions/cache@v4
with:
path: .cache/test
key: ${{ runner.os }}-docker-cache-test-${{ hashFiles('**/Dockerfile', '**/docker-bake.hcl', 'go.mod', 'go.sum') }}
restore-keys: |
${{ runner.os }}-docker-cache-test-
${{ runner.os }}-docker-cache-
- name: Run tests with Docker Bake
run: |
set -euo pipefail
docker buildx bake \
--set "*.cache-from=type=local,src=.cache/test" \
--set "*.cache-to=type=local,dest=.cache/test" \
test
- name: Upload coverage reports
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-reports
path: |
coverage.out
coverage.html
# Build job using Docker Bake
build:
name: Build
runs-on: ubuntu-latest
needs: [lint, test]
permissions:
contents: read
packages: read
env:
VERSION: ${{ github.sha }}
COMMIT: ${{ github.sha }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers - Build
uses: actions/cache@v4
with:
path: .cache/build
key: ${{ runner.os }}-docker-cache-build-${{ hashFiles('**/Dockerfile', '**/docker-bake.hcl', 'go.mod', 'go.sum') }}
restore-keys: |
${{ runner.os }}-docker-cache-build-
${{ runner.os }}-docker-cache-
- name: Build with Docker Bake
run: |
set -euo pipefail
BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
docker buildx bake \
--set "*.cache-from=type=local,src=.cache/build" \
--set "*.cache-to=type=local,dest=.cache/build" \
--set "*.args.VERSION=${VERSION}" \
--set "*.args.COMMIT=${COMMIT}" \
--set "*.args.BUILD_TIME=${BUILD_TIME}" \
build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: binaries
path: bin/