Skip to content

Commit d5596ef

Browse files
refactor: Reduce code duplication in workflows
1 parent 63b9500 commit d5596ef

File tree

2 files changed

+117
-306
lines changed

2 files changed

+117
-306
lines changed

.github/workflows/ci.yml

Lines changed: 51 additions & 306 deletions
Original file line numberDiff line numberDiff line change
@@ -13,332 +13,77 @@ permissions:
1313
jobs:
1414
# Rust Components
1515
confidence-resolver:
16-
name: Confidence Resolver (Rust)
17-
runs-on: ubuntu-latest
18-
steps:
19-
- name: Checkout
20-
uses: actions/checkout@v4
21-
22-
- name: Set up Docker Buildx
23-
uses: docker/setup-buildx-action@v3
24-
25-
- name: Login to GitHub Container Registry
26-
if: github.event_name == 'push'
27-
uses: docker/login-action@v3
28-
with:
29-
registry: ghcr.io
30-
username: ${{ github.actor }}
31-
password: ${{ secrets.GITHUB_TOKEN }}
32-
33-
- name: Test
34-
uses: docker/build-push-action@v6
35-
with:
36-
context: .
37-
target: confidence-resolver.test
38-
push: false
39-
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main
40-
cache-to: ${{ github.event_name == 'push' && 'type=registry,ref=ghcr.io/${{ github.repository }}/cache:main,mode=max' || '' }}
41-
42-
- name: Lint
43-
uses: docker/build-push-action@v6
44-
with:
45-
context: .
46-
target: confidence-resolver.lint
47-
push: false
48-
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main
49-
cache-to: ${{ github.event_name == 'push' && 'type=registry,ref=ghcr.io/${{ github.repository }}/cache:main,mode=max' || '' }}
16+
uses: ./.github/workflows/docker-build.yml
17+
secrets: inherit
18+
with:
19+
job-name: Confidence Resolver (Rust)
20+
targets: confidence-resolver.test,confidence-resolver.lint
5021

5122
wasm-msg:
52-
name: WASM Message (Rust)
53-
runs-on: ubuntu-latest
54-
steps:
55-
- name: Checkout
56-
uses: actions/checkout@v4
57-
58-
- name: Set up Docker Buildx
59-
uses: docker/setup-buildx-action@v3
60-
61-
- name: Login to GitHub Container Registry
62-
if: github.event_name == 'push'
63-
uses: docker/login-action@v3
64-
with:
65-
registry: ghcr.io
66-
username: ${{ github.actor }}
67-
password: ${{ secrets.GITHUB_TOKEN }}
68-
69-
- name: Test
70-
uses: docker/build-push-action@v6
71-
with:
72-
context: .
73-
target: wasm-msg.test
74-
push: false
75-
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main
76-
cache-to: ${{ github.event_name == 'push' && 'type=registry,ref=ghcr.io/${{ github.repository }}/cache:main,mode=max' || '' }}
77-
78-
- name: Lint
79-
uses: docker/build-push-action@v6
80-
with:
81-
context: .
82-
target: wasm-msg.lint
83-
push: false
84-
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main
85-
cache-to: ${{ github.event_name == 'push' && 'type=registry,ref=ghcr.io/${{ github.repository }}/cache:main,mode=max' || '' }}
23+
uses: ./.github/workflows/docker-build.yml
24+
secrets: inherit
25+
with:
26+
job-name: WASM Message (Rust)
27+
targets: wasm-msg.test,wasm-msg.lint
8628

8729
wasm-rust-guest:
88-
name: WASM Rust Guest
89-
runs-on: ubuntu-latest
90-
steps:
91-
- name: Checkout
92-
uses: actions/checkout@v4
93-
94-
- name: Set up Docker Buildx
95-
uses: docker/setup-buildx-action@v3
96-
97-
- name: Login to GitHub Container Registry
98-
if: github.event_name == 'push'
99-
uses: docker/login-action@v3
100-
with:
101-
registry: ghcr.io
102-
username: ${{ github.actor }}
103-
password: ${{ secrets.GITHUB_TOKEN }}
104-
105-
- name: Build
106-
uses: docker/build-push-action@v6
107-
with:
108-
context: .
109-
target: wasm-rust-guest.build
110-
push: false
111-
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main
112-
cache-to: ${{ github.event_name == 'push' && 'type=registry,ref=ghcr.io/${{ github.repository }}/cache:main,mode=max' || '' }}
113-
114-
- name: Lint
115-
uses: docker/build-push-action@v6
116-
with:
117-
context: .
118-
target: wasm-rust-guest.lint
119-
push: false
120-
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main
121-
cache-to: ${{ github.event_name == 'push' && 'type=registry,ref=ghcr.io/${{ github.repository }}/cache:main,mode=max' || '' }}
122-
123-
- name: Extract WASM artifact
124-
run: |
125-
mkdir -p artifacts
126-
docker build --target=wasm-rust-guest.artifact --output=type=local,dest=./artifacts .
127-
128-
- name: Upload WASM artifact
129-
uses: actions/upload-artifact@v4
130-
with:
131-
name: wasm-module
132-
path: artifacts/confidence_resolver.wasm
30+
uses: ./.github/workflows/docker-build.yml
31+
secrets: inherit
32+
with:
33+
job-name: WASM Rust Guest
34+
targets: wasm-rust-guest.build,wasm-rust-guest.lint
35+
upload-artifact: true
13336

13437
cloudflare-resolver:
135-
name: Cloudflare Resolver (Rust)
136-
runs-on: ubuntu-latest
137-
steps:
138-
- name: Checkout
139-
uses: actions/checkout@v4
140-
141-
- name: Set up Docker Buildx
142-
uses: docker/setup-buildx-action@v3
143-
144-
- name: Login to GitHub Container Registry
145-
if: github.event_name == 'push'
146-
uses: docker/login-action@v3
147-
with:
148-
registry: ghcr.io
149-
username: ${{ github.actor }}
150-
password: ${{ secrets.GITHUB_TOKEN }}
151-
152-
- name: Lint
153-
uses: docker/build-push-action@v6
154-
with:
155-
context: .
156-
target: confidence-cloudflare-resolver.lint
157-
push: false
158-
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main
159-
cache-to: ${{ github.event_name == 'push' && 'type=registry,ref=ghcr.io/${{ github.repository }}/cache:main,mode=max' || '' }}
38+
uses: ./.github/workflows/docker-build.yml
39+
secrets: inherit
40+
with:
41+
job-name: Cloudflare Resolver (Rust)
42+
targets: confidence-cloudflare-resolver.lint
16043

16144
# OpenFeature Providers
16245
openfeature-js:
163-
name: OpenFeature Provider (JS)
164-
runs-on: ubuntu-latest
165-
steps:
166-
- name: Checkout
167-
uses: actions/checkout@v4
168-
169-
- name: Set up Docker Buildx
170-
uses: docker/setup-buildx-action@v3
171-
172-
- name: Login to GitHub Container Registry
173-
if: github.event_name == 'push'
174-
uses: docker/login-action@v3
175-
with:
176-
registry: ghcr.io
177-
username: ${{ github.actor }}
178-
password: ${{ secrets.GITHUB_TOKEN }}
179-
180-
- name: Test
181-
uses: docker/build-push-action@v6
182-
with:
183-
context: .
184-
target: openfeature-provider-js.test
185-
push: false
186-
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main
187-
cache-to: ${{ github.event_name == 'push' && 'type=registry,ref=ghcr.io/${{ github.repository }}/cache:main,mode=max' || '' }}
188-
189-
- name: Build
190-
uses: docker/build-push-action@v6
191-
with:
192-
context: .
193-
target: openfeature-provider-js.build
194-
push: false
195-
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main
196-
cache-to: ${{ github.event_name == 'push' && 'type=registry,ref=ghcr.io/${{ github.repository }}/cache:main,mode=max' || '' }}
46+
uses: ./.github/workflows/docker-build.yml
47+
secrets: inherit
48+
with:
49+
job-name: OpenFeature Provider (JS)
50+
targets: openfeature-provider-js.test,openfeature-provider-js.build
19751

19852
openfeature-java:
199-
name: OpenFeature Provider (Java)
200-
runs-on: ubuntu-latest
201-
steps:
202-
- name: Checkout
203-
uses: actions/checkout@v4
204-
205-
- name: Set up Docker Buildx
206-
uses: docker/setup-buildx-action@v3
207-
208-
- name: Login to GitHub Container Registry
209-
if: github.event_name == 'push'
210-
uses: docker/login-action@v3
211-
with:
212-
registry: ghcr.io
213-
username: ${{ github.actor }}
214-
password: ${{ secrets.GITHUB_TOKEN }}
215-
216-
- name: Test
217-
uses: docker/build-push-action@v6
218-
with:
219-
context: .
220-
target: openfeature-provider-java.test
221-
push: false
222-
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main
223-
cache-to: ${{ github.event_name == 'push' && 'type=registry,ref=ghcr.io/${{ github.repository }}/cache:main,mode=max' || '' }}
224-
225-
- name: Build
226-
uses: docker/build-push-action@v6
227-
with:
228-
context: .
229-
target: openfeature-provider-java.build
230-
push: false
231-
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main
232-
cache-to: ${{ github.event_name == 'push' && 'type=registry,ref=ghcr.io/${{ github.repository }}/cache:main,mode=max' || '' }}
53+
uses: ./.github/workflows/docker-build.yml
54+
secrets: inherit
55+
with:
56+
job-name: OpenFeature Provider (Java)
57+
targets: openfeature-provider-java.test,openfeature-provider-java.build
23358

23459
# Integration Tests (Host Examples)
23560
node-host:
236-
name: Node.js Host Integration
237-
runs-on: ubuntu-latest
238-
steps:
239-
- name: Checkout
240-
uses: actions/checkout@v4
241-
242-
- name: Set up Docker Buildx
243-
uses: docker/setup-buildx-action@v3
244-
245-
- name: Login to GitHub Container Registry
246-
if: github.event_name == 'push'
247-
uses: docker/login-action@v3
248-
with:
249-
registry: ghcr.io
250-
username: ${{ github.actor }}
251-
password: ${{ secrets.GITHUB_TOKEN }}
252-
253-
- name: Test
254-
uses: docker/build-push-action@v6
255-
with:
256-
context: .
257-
target: node-host.test
258-
push: false
259-
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main
260-
cache-to: ${{ github.event_name == 'push' && 'type=registry,ref=ghcr.io/${{ github.repository }}/cache:main,mode=max' || '' }}
61+
uses: ./.github/workflows/docker-build.yml
62+
secrets: inherit
63+
with:
64+
job-name: Node.js Host Integration
65+
targets: node-host.test
26166

26267
java-host:
263-
name: Java Host Integration
264-
runs-on: ubuntu-latest
265-
steps:
266-
- name: Checkout
267-
uses: actions/checkout@v4
268-
269-
- name: Set up Docker Buildx
270-
uses: docker/setup-buildx-action@v3
271-
272-
- name: Login to GitHub Container Registry
273-
if: github.event_name == 'push'
274-
uses: docker/login-action@v3
275-
with:
276-
registry: ghcr.io
277-
username: ${{ github.actor }}
278-
password: ${{ secrets.GITHUB_TOKEN }}
279-
280-
- name: Test
281-
uses: docker/build-push-action@v6
282-
with:
283-
context: .
284-
target: java-host.test
285-
push: false
286-
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main
287-
cache-to: ${{ github.event_name == 'push' && 'type=registry,ref=ghcr.io/${{ github.repository }}/cache:main,mode=max' || '' }}
68+
uses: ./.github/workflows/docker-build.yml
69+
secrets: inherit
70+
with:
71+
job-name: Java Host Integration
72+
targets: java-host.test
28873

28974
go-host:
290-
name: Go Host Integration
291-
runs-on: ubuntu-latest
292-
steps:
293-
- name: Checkout
294-
uses: actions/checkout@v4
295-
296-
- name: Set up Docker Buildx
297-
uses: docker/setup-buildx-action@v3
298-
299-
- name: Login to GitHub Container Registry
300-
if: github.event_name == 'push'
301-
uses: docker/login-action@v3
302-
with:
303-
registry: ghcr.io
304-
username: ${{ github.actor }}
305-
password: ${{ secrets.GITHUB_TOKEN }}
306-
307-
- name: Test
308-
uses: docker/build-push-action@v6
309-
with:
310-
context: .
311-
target: go-host.test
312-
push: false
313-
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main
314-
cache-to: ${{ github.event_name == 'push' && 'type=registry,ref=ghcr.io/${{ github.repository }}/cache:main,mode=max' || '' }}
75+
uses: ./.github/workflows/docker-build.yml
76+
secrets: inherit
77+
with:
78+
job-name: Go Host Integration
79+
targets: go-host.test
31580

31681
python-host:
317-
name: Python Host Integration
318-
runs-on: ubuntu-latest
319-
steps:
320-
- name: Checkout
321-
uses: actions/checkout@v4
322-
323-
- name: Set up Docker Buildx
324-
uses: docker/setup-buildx-action@v3
325-
326-
- name: Login to GitHub Container Registry
327-
if: github.event_name == 'push'
328-
uses: docker/login-action@v3
329-
with:
330-
registry: ghcr.io
331-
username: ${{ github.actor }}
332-
password: ${{ secrets.GITHUB_TOKEN }}
333-
334-
- name: Test
335-
uses: docker/build-push-action@v6
336-
with:
337-
context: .
338-
target: python-host.test
339-
push: false
340-
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main
341-
cache-to: ${{ github.event_name == 'push' && 'type=registry,ref=ghcr.io/${{ github.repository }}/cache:main,mode=max' || '' }}
82+
uses: ./.github/workflows/docker-build.yml
83+
secrets: inherit
84+
with:
85+
job-name: Python Host Integration
86+
targets: python-host.test
34287

34388
# Summary job that depends on all others
34489
summary:

0 commit comments

Comments
 (0)