Skip to content

Commit

Permalink
Merge pull request #41 from codecov/pr41
Browse files Browse the repository at this point in the history
monorepo prep: use contextual cache names, add working_directory input
  • Loading branch information
matt-codecov authored Feb 20, 2025
2 parents 40e7f63 + 54f61e0 commit 0b65427
Show file tree
Hide file tree
Showing 11 changed files with 183 additions and 46 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/build-and-push-dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ on:
type: boolean
default: true
description: "Whether to push the image"
working_directory:
type: string
default: .

env:
DOCKERHUB_REPO: ${{ inputs.repo }}
Expand All @@ -30,9 +33,14 @@ jobs:
build-and-push:
name: Build and push
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.working_directory }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Cache Image
id: cache-image
Expand All @@ -42,7 +50,7 @@ jobs:
cache-name: cache-${{ inputs.image_name }}
with:
path: |
${{ inputs.image_name }}.tar
${{ inputs.working_directory }}/${{ inputs.image_name }}.tar
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}

- name: Load built image
Expand Down
17 changes: 12 additions & 5 deletions .github/workflows/build-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
cache_requirements:
type: boolean
default: true
working_directory:
type: string
default: .

env:
AR_REPO: ${{ inputs.repo }}
Expand All @@ -17,11 +20,15 @@ jobs:
build:
name: Build App
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.working_directory }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
submodules: 'recursive'
- id: "auth"
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
name: "Authenticate to Google Cloud"
Expand All @@ -41,22 +48,22 @@ jobs:
if: inputs.cache_requirements
uses: actions/cache@v4
env:
cache-name: cache-requirements
cache-name: ${{ inputs.repo }}-requirements
with:
path: |
requirements.tar
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/docker/Dockerfile.requirements') }}
${{ inputs.working_directory }}/requirements.tar
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles(format('{0}/**/requirements.txt', inputs.working_directory)) }}-${{ hashFiles(format('{0}/**/docker/Dockerfile.requirements', inputs.working_directory)) }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
- name: Cache App
id: cache-app
uses: actions/cache@v4
env:
cache-name: cache-app
cache-name: ${{ inputs.repo }}-app
with:
path: |
app.tar
${{ inputs.working_directory }}/app.tar
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}

- name: Load requirements from cache
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/codecov-startup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,24 @@ name: Codecov Startup

on:
workflow_call:
inputs:
working_directory:
type: string
default: .

jobs:
codecovstartup:
name: Codecov Startup
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.working_directory }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
submodules: 'recursive'
- name: Install CLI
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
Expand All @@ -38,4 +46,4 @@ jobs:
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
codecovcli -u ${{ secrets.CODECOV_PUBLIC_QA_URL }} create-commit -t ${{ secrets.CODECOV_PUBLIC_QA_TOKEN }} --fail-on-error
codecovcli -u ${{ secrets.CODECOV_PUBLIC_QA_URL }} create-report -t ${{ secrets.CODECOV_PUBLIC_QA_TOKEN }} --fail-on-error
codecovcli -u ${{ secrets.CODECOV_PUBLIC_QA_URL }} create-report -t ${{ secrets.CODECOV_PUBLIC_QA_TOKEN }} --fail-on-error
4 changes: 3 additions & 1 deletion .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Import GPG key
id: import-gpg
Expand Down Expand Up @@ -49,4 +51,4 @@ jobs:
reviewers: ${{ github.event.issue.user.login }}
body: |
Release PR for ${{ github.event.inputs.versionName }}
I've updated the version name and committed: ${{ steps.make-commit.outputs.commit }}.
I've updated the version name and committed: ${{ steps.make-commit.outputs.commit }}.
11 changes: 10 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,23 @@ name: Run Lint

on:
workflow_call:
inputs:
working_directory:
type: string
default: .

jobs:
lint:
name: Run Lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.working_directory }}
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Install dependencies
run: make lint.install
- name: Check
run: make lint.check
run: make lint.check
8 changes: 8 additions & 0 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@ on:
required: false
default: ""
description: "Extra configuration for mypy"
working_directory:
type: string
default: .

jobs:
static-type-check:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.working_directory }}
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- uses: actions/setup-python@v5
with:
python-version: "3.12"
Expand Down
33 changes: 26 additions & 7 deletions .github/workflows/push-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ on:
type: boolean
default: false
description: "Whether to push the release image"
working_directory:
type: string
default: .
sentry_project:
type: string
required: false

env:
AR_REPO: ${{ inputs.repo }}
Expand All @@ -29,13 +35,17 @@ jobs:
push-environment:
name: Push ${{ inputs.environment }} Image
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.working_directory }}
environment: ${{ inputs.environment }}
if: github.repository_owner == 'codecov' && !inputs.push_rolling && !inputs.push_release
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
- name: Get Release SHA
env:
SHA: ${{ github.sha }}
Expand All @@ -45,10 +55,10 @@ jobs:
id: cache-app
uses: actions/cache@v4
env:
cache-name: cache-app
cache-name: ${{ inputs.repo }}-app
with:
path: |
app.tar
${{ inputs.working_directory }}/app.tar
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
- name: Load built image
run: |
Expand Down Expand Up @@ -81,28 +91,33 @@ jobs:
env:
SENTRY_AUTH_TOKEN: ${{ secrets.CODECOV_SENTRY_RELEASE_TOKEN }}
SENTRY_ORG: ${{ secrets.CODECOV_SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.CODECOV_SENTRY_PROJECT }}
SENTRY_PROJECT: ${{ inputs.sentry_project != '' && inputs.sentry_project || secrets.CODECOV_SENTRY_PROJECT }}
with:
environment: ${{ inputs.environment }}
version: ${{ inputs.environment }}-release-${{ steps.sha.outputs.short_sha }}
ignore_missing: true
working_directory: ${{ inputs.working_directory }}
rolling:
name: Push Rolling Image
if: inputs.push_rolling == true && github.repository_owner == 'codecov' && !github.event.pull_request.head.repo.fork
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.working_directory }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
- name: Cache App
id: cache-app
uses: actions/cache@v4
env:
cache-name: cache-app
cache-name: ${{ inputs.repo }}-app
with:
path: |
app.tar
${{ inputs.working_directory }}/app.tar
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
- name: Load built image
run: |
Expand All @@ -120,19 +135,23 @@ jobs:
name: Push Release Image
if: inputs.push_release == true && github.repository_owner == 'codecov' && !github.event.pull_request.head.repo.fork
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.working_directory }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
- name: Cache App
id: cache-app
uses: actions/cache@v4
env:
cache-name: cache-app
cache-name: ${{ inputs.repo }}-app
with:
path: |
app.tar
${{ inputs.working_directory }}/app.tar
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
- name: Load built image
run: |
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/run-ats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,33 @@ on:
type: string
default: "--codecov-yml-path=codecov_cli.yml"
description: "Path to codecov cli yml. Currently expected to include flag as well --codecov-yml-path=codecov_cli.yml for ex."
working_directory:
type: string
default: .
env:
AR_REPO: ${{ inputs.repo }}

jobs:
ats:
name: ATS
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.working_directory }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
- name: Cache App
id: cache-app
uses: actions/cache@v4
env:
cache-name: cache-app
cache-name: ${{ inputs.repo }}-app
with:
path: |
app.tar
${{ inputs.working_directory }}/app.tar
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
- name: Load built image
run: |
Expand Down Expand Up @@ -89,6 +96,8 @@ jobs:
make test_env.label_analysis CODECOV_STATIC_TOKEN=${{ secrets.STATIC_TOKEN }} CODECOV_URL=${{ secrets.CODECOV_ATS_URL }}
make test_env.ats CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_ORG_TOKEN }} CODECOV_URL=${{ secrets.CODECOV_ATS_URL }}
- id: test-upload-action
# NOTE: `defaults.runs.working-directory` will not be propagated into this action.
# This action will only work with the default working directory (the repo root).
uses: codecov/codecov-ats-docker@main
if: inputs.use_action
name: Run tests and upload to Codecov via action
Expand Down
Loading

0 comments on commit 0b65427

Please sign in to comment.