Skip to content

Commit

Permalink
ci: Apply Graphite CI Optimizer (#2484)
Browse files Browse the repository at this point in the history
  • Loading branch information
achimnol authored Jul 17, 2024
1 parent 9bb978c commit f12b395
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 33 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/alembic-head-check.yml

This file was deleted.

74 changes: 67 additions & 7 deletions .github/workflows/default.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: default
name: ci

on:
push:
Expand All @@ -11,8 +11,27 @@ concurrency:
cancel-in-progress: true

jobs:

optimize-ci:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.check_skip.outputs.skip }}
steps:
- name: Optimize CI
id: check_skip
uses: withgraphite/graphite-ci-action@main
with:
graphite_token: ${{ secrets.GRAPHITE_CI_OPTIMIZER_TOKEN }}


lint:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') && !contains(fromJSON('["flow:merge-queue", "flow:hotfix"]'), github.event.label.name) && github.event.pull_request.merged == false }}
if: |
${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci')
&& !contains(fromJSON('["flow:merge-queue", "flow:hotfix"]'), github.event.label.name)
&& github.event.pull_request.merged == false
&& needs.optimize-ci.outputs.skip == 'false'
}}
needs: [optimize-ci]
runs-on: ubuntu-latest
steps:
- name: Calculate the fetch depth
Expand Down Expand Up @@ -80,8 +99,41 @@ jobs:
if: always() # We want the log even on failures.


alembic-check-multiple-heads:
if: |
${{ contains(github.event.pull_request.labels.*.name, 'require:db-migration')
&& !contains(fromJSON('["flow:merge-queue", "flow:hotfix"]'), github.event.label.name)
&& github.event.pull_request.merged == false
&& needs.optimize-ci.outputs.skip == 'false'
}}
needs: [optimize-ci]
runs-on: ubuntu-latest
steps:
- name: Check out the revision
uses: actions/checkout@v4
with:
lfs: false
- name: Parse versions from config
run: |
PYTHON_VERSION=$(grep -m 1 -oP '(?<=CPython==)([^"]+)' pants.toml)
echo "PANTS_CONFIG_FILES=pants.ci.toml" >> $GITHUB_ENV
echo "PROJECT_PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_ENV
- name: Set up Python as Runtime
uses: actions/setup-python@v5
with:
python-version: ${{ env.PROJECT_PYTHON_VERSION }}
- name: Check for multiple heads
run: python scripts/check-multiple-alembic-heads.py


typecheck:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') && !contains(fromJSON('["flow:merge-queue", "flow:hotfix"]'), github.event.label.name) && github.event.pull_request.merged == false }}
if: |
${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci')
&& !contains(fromJSON('["flow:merge-queue", "flow:hotfix"]'), github.event.label.name)
&& github.event.pull_request.merged == false
&& needs.optimize-ci.outputs.skip == 'false'
}}
needs: [optimize-ci]
runs-on: ubuntu-latest
steps:
- name: Calculate the fetch depth
Expand Down Expand Up @@ -146,7 +198,13 @@ jobs:


test:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') && !contains(fromJSON('["flow:merge-queue", "flow:hotfix"]'), github.event.label.name) && github.event.pull_request.merged == false }}
if: |
${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci')
&& !contains(fromJSON('["flow:merge-queue", "flow:hotfix"]'), github.event.label.name)
&& github.event.pull_request.merged == false
&& needs.optimize-ci.outputs.skip == 'false'
}}
needs: [optimize-ci]
runs-on: [ubuntu-latest-8-cores]
steps:
- name: Calculate the fetch depth
Expand Down Expand Up @@ -211,7 +269,7 @@ jobs:


build-scies:
needs: [lint, typecheck, test]
needs: [lint, typecheck, test, alembic-check-multiple-heads]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
strategy:
fail-fast: false
Expand Down Expand Up @@ -270,7 +328,7 @@ jobs:


build-wheels:
needs: [lint, typecheck, test]
needs: [lint, typecheck, test, alembic-check-multiple-heads]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -335,11 +393,13 @@ jobs:
path: .pants.d/workdir/pants.log
if: always() # We want the log even on failures.


build-sbom:
needs: [lint, typecheck, test]
needs: [lint, typecheck, test, alembic-check-multiple-heads]
if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}
uses: ./.github/workflows/sbom.yml


make-final-release:
needs: [build-scies, build-wheels, build-sbom]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
Expand Down

0 comments on commit f12b395

Please sign in to comment.