Skip to content

Commit bce20a8

Browse files
committed
add makefile prefix, custom reqs cache key args
1 parent 0a848a0 commit bce20a8

File tree

7 files changed

+103
-112
lines changed

7 files changed

+103
-112
lines changed

.github/workflows/build-and-push-dockerhub.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ on:
2020
type: boolean
2121
default: true
2222
description: "Whether to push the image"
23-
working_directory:
23+
output_directory:
2424
type: string
2525
default: .
26+
make_target_prefix:
27+
type: string
28+
default: ""
2629

2730
env:
2831
DOCKERHUB_REPO: ${{ inputs.repo }}
@@ -33,9 +36,6 @@ jobs:
3336
build-and-push:
3437
name: Build and push
3538
runs-on: ubuntu-latest
36-
defaults:
37-
run:
38-
working-directory: ${{ inputs.working_directory }}
3939
steps:
4040
- name: Checkout
4141
uses: actions/checkout@v4
@@ -50,19 +50,19 @@ jobs:
5050
cache-name: cache-${{ inputs.image_name }}
5151
with:
5252
path: |
53-
${{ inputs.working_directory }}/${{ inputs.image_name }}.tar
53+
${{ inputs.output_directory }}/${{ inputs.image_name }}.tar
5454
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
5555

5656
- name: Load built image
5757
if: ${{ inputs.cache && steps.cache-image.outputs.cache-hit == 'true' }}
5858
run: |
59-
make load.${{ inputs.image_name }}
59+
make ${{ inputs.make_target_prefix }}load.${{ inputs.image_name }}
6060
6161
- name: Build image
6262
if: ${{ !inputs.cache || steps.cache-image.outputs.cache-hit != 'true' }}
6363
run: |
64-
make build.${{ inputs.image_name }}
65-
make save.${{ inputs.image_name }}
64+
make ${{ inputs.make_target_prefix }}build.${{ inputs.image_name }}
65+
make ${{ inputs.make_target_prefix }}save.${{ inputs.image_name }}
6666
6767
- name: Log in to Docker Hub
6868
uses: docker/[email protected]
@@ -74,5 +74,5 @@ jobs:
7474
- name: Push image
7575
if: ${{ inputs.push && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
7676
run: |
77-
make tag.${{ inputs.image_name }}
78-
make push.${{ inputs.image_name }}
77+
make ${{ inputs.make_target_prefix }}tag.${{ inputs.image_name }}
78+
make ${{ inputs.make_target_prefix }}push.${{ inputs.image_name }}

.github/workflows/build-app.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@ on:
99
cache_requirements:
1010
type: boolean
1111
default: true
12-
working_directory:
12+
output_directory:
1313
type: string
1414
default: .
15+
reqs_cache_key:
16+
type: string
17+
required: false
1518
cache_file:
1619
type: string
1720
default: "requirements.txt"
21+
make_target_prefix:
22+
type: string
23+
default: ""
1824

1925
env:
2026
AR_REPO: ${{ inputs.repo }}
@@ -23,9 +29,6 @@ jobs:
2329
build:
2430
name: Build App
2531
runs-on: ubuntu-latest
26-
defaults:
27-
run:
28-
working-directory: ${{ inputs.working_directory }}
2932
steps:
3033
- name: Checkout
3134
uses: actions/checkout@v4
@@ -54,8 +57,8 @@ jobs:
5457
cache-name: ${{ inputs.repo }}-requirements
5558
with:
5659
path: |
57-
${{ inputs.working_directory }}/requirements.tar
58-
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles(format('{0}/**/{1}', inputs.working_directory, inputs.cache_file)) }}-${{ hashFiles(format('{0}/**/docker/Dockerfile.requirements', inputs.working_directory)) }}
60+
${{ inputs.output_directory }}/requirements.tar
61+
key: ${{ runner.os }}-${{ env.cache_name }}-${{ inputs.reqs_cache_key || format('{0}-{1}', hashFiles(format('{0}/**/{1}', inputs.output_directory, inputs.cache_file)), hashFiles(format('{0}/**/docker/Dockerfile.requirements', inputs.output_directory))) }}
5962
restore-keys: |
6063
${{ runner.os }}-${{ env.cache-name }}-
6164
@@ -66,25 +69,25 @@ jobs:
6669
cache-name: ${{ inputs.repo }}-app
6770
with:
6871
path: |
69-
${{ inputs.working_directory }}/app.tar
72+
${{ inputs.output_directory }}/app.tar
7073
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
7174

7275
- name: Load requirements from cache
7376
if: ${{ steps.cache-requirements.outputs.cache-hit == 'true' && inputs.cache_requirements }}
7477
run: |
75-
make load.requirements
78+
make ${{ inputs.make_target_prefix }}load.requirements
7679
7780
- name: Build/pull requirements
7881
if: ${{ steps.cache-requirements.outputs.cache-hit != 'true' && inputs.cache_requirements }}
7982
run: |
80-
make build.requirements
81-
make save.requirements
83+
make ${{ inputs.make_target_prefix }}build.requirements
84+
make ${{ inputs.make_target_prefix }}save.requirements
8285
8386
- name: Push Requirements
8487
if: ${{ steps.cache-requirements.outputs.cache-hit != 'true' && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' && inputs.cache_requirements }}
8588
run: |
86-
make push.requirements
89+
make ${{ inputs.make_target_prefix }}push.requirements
8790
- name: Build app
8891
run: |
89-
make build.app
90-
make save.app
92+
make ${{ inputs.make_target_prefix }}build.app
93+
make ${{ inputs.make_target_prefix }}save.app

.github/workflows/lint.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,19 @@ name: Run Lint
44
on:
55
workflow_call:
66
inputs:
7-
working_directory:
7+
make_target_prefix:
88
type: string
9-
default: .
9+
default: ""
1010

1111
jobs:
1212
lint:
1313
name: Run Lint
1414
runs-on: ubuntu-latest
15-
defaults:
16-
run:
17-
working-directory: ${{ inputs.working_directory }}
1815
steps:
1916
- uses: actions/checkout@v4
2017
with:
2118
submodules: 'recursive'
2219
- name: Install dependencies
23-
run: make lint.install
20+
run: make ${{ inputs.make_target_prefix }}lint.install
2421
- name: Check
25-
run: make lint.check
22+
run: make ${{ inputs.make_target_prefix }}lint.check

.github/workflows/push-env.yml

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ on:
2121
type: boolean
2222
default: false
2323
description: "Whether to push the release image"
24-
working_directory:
24+
output_directory:
2525
type: string
2626
default: .
27+
make_target_prefix:
28+
type: string
29+
default: ""
2730
sentry_project:
2831
type: string
2932
required: false
@@ -35,9 +38,6 @@ jobs:
3538
push-environment:
3639
name: Push ${{ inputs.environment }} Image
3740
runs-on: ubuntu-latest
38-
defaults:
39-
run:
40-
working-directory: ${{ inputs.working_directory }}
4141
environment: ${{ inputs.environment }}
4242
if: github.repository_owner == 'codecov' && !inputs.push_rolling && !inputs.push_release
4343
steps:
@@ -58,7 +58,7 @@ jobs:
5858
cache-name: ${{ inputs.repo }}-app
5959
with:
6060
path: |
61-
${{ inputs.working_directory }}/app.tar
61+
${{ inputs.output_directory }}/app.tar
6262
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
6363
- name: Load built image
6464
run: |
@@ -77,13 +77,13 @@ jobs:
7777
7878
- name: Push ${{ inputs.environment }}
7979
run: |
80-
make tag.${{ inputs.environment }}
81-
make push.${{ inputs.environment }}
80+
make ${{ inputs.make_target_prefix }}tag.${{ inputs.environment }}
81+
make ${{ inputs.make_target_prefix }}push.${{ inputs.environment }}
8282
- name: Push latest
8383
if: inputs.environment == 'production'
8484
run: |
85-
make tag.latest
86-
make push.latest
85+
make ${{ inputs.make_target_prefix }}tag.latest
86+
make ${{ inputs.make_target_prefix }}push.latest
8787
8888
- name: Create Sentry release
8989
if: inputs.create_sentry_release
@@ -96,14 +96,11 @@ jobs:
9696
environment: ${{ inputs.environment }}
9797
version: ${{ inputs.environment }}-release-${{ steps.sha.outputs.short_sha }}
9898
ignore_missing: true
99-
working_directory: ${{ inputs.working_directory }}
99+
output_directory: ${{ inputs.output_directory }}
100100
rolling:
101101
name: Push Rolling Image
102102
if: inputs.push_rolling == true && github.repository_owner == 'codecov' && !github.event.pull_request.head.repo.fork
103103
runs-on: ubuntu-latest
104-
defaults:
105-
run:
106-
working-directory: ${{ inputs.working_directory }}
107104
steps:
108105
- name: Checkout
109106
uses: actions/checkout@v4
@@ -117,7 +114,7 @@ jobs:
117114
cache-name: ${{ inputs.repo }}-app
118115
with:
119116
path: |
120-
${{ inputs.working_directory }}/app.tar
117+
${{ inputs.output_directory }}/app.tar
121118
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
122119
- name: Load built image
123120
run: |
@@ -129,15 +126,12 @@ jobs:
129126
password: ${{ secrets.CODECOV_DEVOPS_DOCKER_PASSWORD }}
130127
- name: Push Rolling
131128
run: |
132-
make tag.rolling
133-
make push.rolling
129+
make ${{ inputs.make_target_prefix }}tag.rolling
130+
make ${{ inputs.make_target_prefix }}push.rolling
134131
release:
135132
name: Push Release Image
136133
if: inputs.push_release == true && github.repository_owner == 'codecov' && !github.event.pull_request.head.repo.fork
137134
runs-on: ubuntu-latest
138-
defaults:
139-
run:
140-
working-directory: ${{ inputs.working_directory }}
141135
steps:
142136
- name: Checkout
143137
uses: actions/checkout@v4
@@ -151,7 +145,7 @@ jobs:
151145
cache-name: ${{ inputs.repo }}-app
152146
with:
153147
path: |
154-
${{ inputs.working_directory }}/app.tar
148+
${{ inputs.output_directory }}/app.tar
155149
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
156150
- name: Load built image
157151
run: |
@@ -163,5 +157,5 @@ jobs:
163157
password: ${{ secrets.CODECOV_DEVOPS_DOCKER_PASSWORD }}
164158
- name: Push release
165159
run: |
166-
make tag.release
167-
make push.release
160+
make ${{ inputs.make_target_prefix }}tag.release
161+
make ${{ inputs.make_target_prefix }}push.release

.github/workflows/run-tests-split.yml

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ on:
1717
flag_prefix:
1818
type: string
1919
default: ''
20-
working_directory:
20+
output_directory:
2121
type: string
2222
default: .
23+
make_target_prefix:
24+
type: string
25+
default: ""
2326
pytest_rootdir:
2427
type: string
2528
default: .
@@ -52,9 +55,6 @@ jobs:
5255
test:
5356
name: Test
5457
runs-on: ubuntu-latest
55-
defaults:
56-
run:
57-
working-directory: ${{ inputs.working_directory }}
5858
needs: [prepare_groups]
5959
strategy:
6060
matrix:
@@ -73,7 +73,7 @@ jobs:
7373
cache-name: ${{ inputs.repo }}-app
7474
with:
7575
path: |
76-
${{ inputs.working_directory }}/app.tar
76+
${{ inputs.output_directory }}/app.tar
7777
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
7878
- name: Load built image
7979
run: |
@@ -84,37 +84,34 @@ jobs:
8484
sudo chmod +x /usr/local/bin/docker-compose
8585
- name: Bring test env up
8686
run: |
87-
make test_env.up
87+
make ${{ inputs.make_target_prefix }}test_env.up
8888
- name: Prepare for tests
8989
run: |
90-
make test_env.prepare
91-
make test_env.check_db
90+
make ${{ inputs.make_target_prefix }}test_env.prepare
91+
make ${{ inputs.make_target_prefix }}test_env.check_db
9292
- name: Run unit tests
9393
run: |
94-
make test_env.run_unit GROUP=${{ matrix.group }} SPLIT=${{ inputs.split }} PYTEST_ROOTDIR=${{ inputs.pytest_rootdir }}
94+
make ${{ inputs.make_target_prefix }}test_env.run_unit GROUP=${{ matrix.group }} SPLIT=${{ inputs.split }} PYTEST_ROOTDIR=${{ inputs.pytest_rootdir }}
9595
- name: Run integration tests
9696
if: inputs.run_integration == true
9797
run: |
98-
make test_env.run_integration GROUP=${{ matrix.group }} SPLIT=${{ inputs.split }} PYTEST_ROOTDIR=${{ inputs.pytest_rootdir }}
98+
make ${{ inputs.make_target_prefix }}test_env.run_integration GROUP=${{ matrix.group }} SPLIT=${{ inputs.split }} PYTEST_ROOTDIR=${{ inputs.pytest_rootdir }}
9999
100100
- uses: actions/upload-artifact@v4
101101
if: ${{ !cancelled() }}
102102
with:
103103
name: ${{ inputs.flag_prefix }}-coveragefiles-${{ matrix.group }}
104-
path: ${{ inputs.working_directory }}/*.coverage.xml
104+
path: ${{ inputs.output_directory }}/*.coverage.xml
105105

106106
- uses: actions/upload-artifact@v4
107107
if: ${{ !cancelled() }}
108108
with:
109109
name: ${{ inputs.flag_prefix }}-junitfiles-${{ matrix.group }}
110-
path: ${{ inputs.working_directory }}/*junit*.xml
110+
path: ${{ inputs.output_directory }}/*junit*.xml
111111

112112
upload:
113113
name: Upload to Codecov
114114
runs-on: ubuntu-latest
115-
defaults:
116-
run:
117-
working-directory: ${{ inputs.working_directory }}
118115
needs: [test]
119116
strategy:
120117
matrix:
@@ -205,7 +202,7 @@ jobs:
205202
# The coverage action will have installed codecovcli with pip. The
206203
# actual binary will be found in $PATH.
207204
binary: codecovcli
208-
working-directory: ${{ inputs.working_directory }}
205+
output-directory: ${{ inputs.output_directory }}
209206

210207
- name: Uploading integration test results (${{ matrix.name }})
211208
if: ${{ inputs.run_integration == true }}
@@ -219,4 +216,4 @@ jobs:
219216
# The coverage action will have installed codecovcli with pip. The
220217
# actual binary will be found in $PATH.
221218
binary: codecovcli
222-
working-directory: ${{ inputs.working_directory }}
219+
output-directory: ${{ inputs.output_directory }}

0 commit comments

Comments
 (0)