Skip to content

Commit cbb62e4

Browse files
feat: migrate CI to formancehq/ci shared workflows
1 parent 2f61bb3 commit cbb62e4

4 files changed

Lines changed: 82 additions & 177 deletions

File tree

.github/actions/default/action.yml

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

.github/actions/env/action.yml

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

.github/workflows/main.yml

Lines changed: 76 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -5,169 +5,132 @@ on:
55
branches:
66
- main
77
- releases/*
8+
- release/*
89
pull_request:
910
types: [ assigned, opened, synchronize, reopened, labeled ]
1011

1112
concurrency:
1213
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1314
cancel-in-progress: true
14-
permissions:
15-
id-token: write
16-
contents: read
15+
1716
jobs:
1817
PR:
1918
if: github.event_name == 'pull_request'
20-
name: Check PR Title
21-
runs-on: namespace-profile-linux-amd64-2vcpu
19+
uses: formancehq/ci/.github/workflows/go-pr.yml@main
2220
permissions:
21+
pull-requests: read
2322
statuses: write
24-
steps:
25-
- uses: amannn/action-semantic-pull-request@v6
26-
env:
27-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2823

2924
Dirty:
3025
runs-on: namespace-profile-linux-amd64-4vcpu
3126
steps:
32-
- uses: "namespacelabs/nscloud-checkout-action@v9"
27+
- uses: namespacelabs/nscloud-checkout-action@v9
3328
with:
3429
fetch-depth: 0
35-
- name: Setup Nix
36-
uses: ./.github/actions/default
37-
with:
38-
token: ${{ secrets.NUMARY_GITHUB_TOKEN }}
39-
- name: Pre-commit
30+
dissociate: true
31+
32+
- uses: formancehq/ci/actions/setup-nix@main
33+
34+
- run: nix develop --impure --command just pc
4035
env:
4136
GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }}
42-
run: nix develop --impure --command just pc
37+
4338
- name: Get changed files
44-
id: changed-files
4539
shell: bash
4640
run: |
47-
hasChanged=$(git status --porcelain)
41+
hasChanged=$(git status --porcelain)
4842
if (( $(echo ${#hasChanged}) != 0 )); then
4943
git status
5044
echo "There are changes in the repository"
5145
exit 1
5246
fi
5347
48+
TestsUnit:
49+
name: Tests (Unit)
50+
needs: [Dirty]
51+
runs-on: namespace-profile-linux-amd64-4vcpu
52+
steps:
53+
- uses: namespacelabs/nscloud-checkout-action@v9
54+
with:
55+
fetch-depth: 0
56+
dissociate: true
57+
58+
- uses: formancehq/ci/actions/setup-nix@main
59+
60+
- run: nix develop --impure --command just tests-unit
61+
62+
- uses: actions/upload-artifact@v7
63+
with:
64+
name: coverage-unit-report
65+
path: ./coverage/unit_filtered.txt
66+
67+
TestsIntegration:
68+
name: Tests (Integration)
69+
needs: [Dirty]
70+
runs-on: namespace-profile-linux-amd64-4vcpu
71+
steps:
72+
- uses: namespacelabs/nscloud-checkout-action@v9
73+
with:
74+
fetch-depth: 0
75+
dissociate: true
76+
77+
- uses: formancehq/ci/actions/setup-nix@main
78+
79+
- run: nix develop --impure --command just tests-integration
80+
81+
- uses: actions/upload-artifact@v7
82+
with:
83+
name: coverage-integration-report
84+
path: ./coverage/integration_filtered.txt
5485

5586
Tests:
56-
runs-on: "namespace-profile-linux-amd64-2vcpu"
87+
runs-on: namespace-profile-linux-amd64-2vcpu
5788
needs:
5889
- TestsUnit
5990
- TestsIntegration
6091
steps:
61-
- name: Download a report artifact
62-
uses: actions/download-artifact@v8
92+
- uses: actions/download-artifact@v8
6393
with:
6494
pattern: coverage-*
6595
merge-multiple: true
66-
- name: Upload coverage reports to Codecov with GitHub Action
67-
uses: codecov/codecov-action@v7.0.0
96+
97+
- uses: codecov/codecov-action@v7.0.0
6898
env:
6999
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
70100
with:
71101
files: unit_filtered.txt,integration_filtered.txt
72-
73-
TestsUnit:
74-
name: Tests (Unit)
75-
runs-on: namespace-profile-linux-amd64-4vcpu
76-
steps:
77-
- uses: "namespacelabs/nscloud-checkout-action@v9"
78-
with:
79-
fetch-depth: 0
80-
- name: Setup Nix
81-
uses: ./.github/actions/default
82-
with:
83-
token: ${{ secrets.NUMARY_GITHUB_TOKEN }}
84-
- name: Pre-commit
85-
run: nix develop --impure --command just tests-unit
86-
- name: Archive code coverage results
87-
uses: actions/upload-artifact@v7
88-
with:
89-
name: coverage-unit-report
90-
path: ./coverage/unit_filtered.txt
91-
92-
TestsIntegration:
93-
name: Tests (Integration)
94-
runs-on: namespace-profile-linux-amd64-4vcpu
95-
steps:
96-
- uses: "namespacelabs/nscloud-checkout-action@v9"
97-
with:
98-
fetch-depth: 0
99-
- name: Setup Nix
100-
uses: ./.github/actions/default
101-
with:
102-
token: ${{ secrets.NUMARY_GITHUB_TOKEN }}
103-
- name: Pre-commit
104-
run: nix develop --impure --command just tests-integration
105-
- name: Archive code coverage results
106-
uses: actions/upload-artifact@v7
107-
with:
108-
name: coverage-integration-report
109-
path: ./coverage/integration_filtered.txt
110102

111103
GoReleaser:
112-
runs-on: "namespace-profile-linux-amd64-4vcpu"
113-
if: contains(github.event.pull_request.labels.*.name, 'build-images') || github.ref == 'refs/heads/main' || github.event_name == 'merge_group'
114-
steps:
115-
- uses: "namespacelabs/nscloud-checkout-action@v9"
116-
with:
117-
fetch-depth: 0
118-
- name: Setup Nix
119-
uses: ./.github/actions/default
120-
with:
121-
token: ${{ secrets.NUMARY_GITHUB_TOKEN }}
122-
- name: Login to GitHub Container Registry
123-
uses: docker/login-action@v4
124-
with:
125-
registry: ghcr.io
126-
username: "NumaryBot"
127-
password: ${{ secrets.NUMARY_GITHUB_TOKEN }}
128-
- run: >
129-
nix develop --impure --command just release-ci
104+
needs: [Dirty]
105+
uses: formancehq/ci/.github/workflows/go-build.yml@main
106+
with:
107+
build-condition: main-and-label
108+
build-label: build-images
109+
secrets:
110+
NUMARY_GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }}
111+
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
130112

131-
env:
132-
GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }}
133-
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
134-
135113
Deploy:
136-
runs-on: ubuntu-24.04
114+
runs-on: namespace-profile-linux-amd64-2vcpu
137115
if: github.ref == 'refs/heads/main'
138116
environment: staging
117+
permissions:
118+
id-token: write
139119
needs:
140120
- GoReleaser
141121
- Dirty
142122
- Tests
143123
steps:
144-
- uses: earthly/actions-setup@v1
145-
with:
146-
github-token: ${{ secrets.GITHUB_TOKEN }}
147-
version: "latest"
148-
- uses: 'actions/checkout@v7'
124+
- uses: formancehq/ci/actions/deploy-staging@main
149125
with:
150-
fetch-depth: 0
151-
- name: Tailscale
152-
uses: tailscale/github-action@v4
153-
with:
154-
oauth-client-id: ${{ secrets.TS_OIDC_OAUTH_CLIENT_ID }}
155-
audience: ${{ secrets.TS_OIDC_AUDIENCE }}
156-
tags: ${{ vars.TS_TAGS }}
157-
version: ${{ vars.TS_VERSION }}
158-
args: ${{ vars.TS_ARGS }}
159-
retry: ${{ vars.TS_RETRY }}
160-
timeout: ${{ vars.TS_TIMEOUT }}
161-
ping: ${{ vars.TS_PING }}
162-
- name: "Deploy in staging"
163-
env:
164-
TAG: ${{ github.sha }}
165-
COMPONENT: agent
166-
ARGOCD_REGION_AUTH_TOKEN: ${{ secrets.ARGOCD_REGION_AUTH_TOKEN }}
167-
run: >
168-
earthly
169-
--no-output
170-
--secret AUTH_TOKEN=$ARGOCD_REGION_AUTH_TOKEN
171-
+deploy-staging
172-
--TAG=$TAG
173-
--COMPONENT=$COMPONENT
126+
component: agent
127+
tag: ${{ github.sha }}
128+
auth-token: ${{ secrets.ARGOCD_REGION_AUTH_TOKEN }}
129+
ts-oauth-client-id: ${{ secrets.TS_OIDC_OAUTH_CLIENT_ID }}
130+
ts-audience: ${{ secrets.TS_OIDC_AUDIENCE }}
131+
ts-tags: ${{ vars.TS_TAGS }}
132+
ts-version: ${{ vars.TS_VERSION }}
133+
ts-args: ${{ vars.TS_ARGS }}
134+
ts-retry: ${{ vars.TS_RETRY }}
135+
ts-timeout: ${{ vars.TS_TIMEOUT }}
136+
ts-ping: ${{ vars.TS_PING }}

.github/workflows/releases.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,21 @@ on:
55
- 'v*.*.*'
66
permissions:
77
contents: write
8+
packages: write
89

910
jobs:
1011
Release:
11-
name: Release
1212
runs-on: namespace-profile-linux-amd64-4vcpu
1313
steps:
14-
- name: Checkout
15-
uses: namespacelabs/nscloud-checkout-action@v9
14+
- uses: namespacelabs/nscloud-checkout-action@v9
1615
with:
1716
fetch-depth: 0
18-
- name: Setup Nix
19-
uses: ./.github/actions/default
17+
dissociate: true
18+
19+
- uses: formancehq/ci/actions/setup-release@main
2020
with:
2121
token: ${{ secrets.NUMARY_GITHUB_TOKEN }}
22-
- name: Configure Git
23-
run: |
24-
git config user.name "$GITHUB_ACTOR"
25-
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
26-
- name: Login to GitHub Container Registry
27-
uses: docker/login-action@v4
28-
with:
29-
registry: ghcr.io
30-
username: "NumaryBot"
31-
password: ${{ secrets.NUMARY_GITHUB_TOKEN }}
22+
3223
- name: Release
3324
run: nix develop --impure --command just release
3425
env:

0 commit comments

Comments
 (0)