Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(BA-778): Modularize common if conditions #3706

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 42 additions & 41 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ jobs:
contents: read
pull-requests: write
outputs:
skip: ${{ steps.check_skip.outputs.SKIP }}
skip: ${{ steps.check_skip.outputs.SKIP_CI }}
graphite-labels: ${{ steps.check_skip.outputs.GRAPHITE_LABELS }}
release: ${{ steps.check_skip.outputs.IS_RELEASE }}
steps:
- name: Debug action trigger
run: |
Expand Down Expand Up @@ -57,32 +59,42 @@ jobs:
echo " github.event.ref: ${{ github.event.ref }}"
echo "---"
echo "concurrency-group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}"
- name: labeler
if: github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize'
uses: lablup/auto-labeler@main # actions/labeler, lablup/size-label-action, lablup/auto-label-in-issue
- name: Optimize CI
id: check_skip
run: |
echo "SKIP=false" >> $GITHUB_OUTPUT
echo "NON_TOP_BOTTOM=false" >> $GITHUB_OUTPUT
BASE_BRANCH=${{ github.event.pull_request.base.ref }}
if [[ "$BASE_BRANCH" != "main" && ! "$BASE_BRANCH" =~ ^[0-9]{2}\.[0-9]{1,2}$ ]]; then
response=$(curl -s -o /dev/null -w "%{http_code}" -X GET "${{ secrets.KVSTORE_URL }}/?key=base_${{ github.event.pull_request.head }}" \
-H "Authorization: Bearer ${{ secrets.KVSTORE_TOKEN }}")
if [ "$response" == "200" ]; then
echo "SKIP=true" >> $GITHUB_OUTPUT
echo "NON_TOP_BOTTOM=true" >> $GITHUB_OUTPUT
fi
fi
- name: labeler
if: github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize'
uses: lablup/auto-labeler@main # actions/labeler, lablup/size-label-action, lablup/auto-label-in-issue
- name: Skip CI
if: |
contains(toJSON(github.event.head_commit.message), 'skip:ci')
|| contains(github.event.pull_request.labels.*.name, 'skip:ci')
|| steps.check_skip.outputs.NON_TOP_BOTTOM == 'true'
run: echo "SKIP_CI=true" >> $GITHUB_OUTPUT
- name: Graphite labels
if: contains(fromJSON('["flow:merge-queue", "flow:hotfix"]'), github.event.pull_request.labels.*.name)
run: |
echo "GRAPHITE_LABELS=true" >> $GITHUB_OUTPUT
- name: Release
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
run: echo "IS_RELEASE=true" >> $GITHUB_OUTPUT




lint:
if: |
!(
contains(toJSON(github.event.commits.*.msg), 'skip:ci')
|| contains(github.event.pull_request.labels.*.name, 'skip:ci')
|| needs.optimize-ci.outputs.skip == 'true'
)
&& !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.outputs.graphite-labels == false
needs: [optimize-ci]
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -155,11 +167,10 @@ jobs:
if: |
(
contains(github.event.pull_request.labels.*.name, 'require:db-migration')
|| (github.event_name == 'push' && contains(github.ref, 'refs/tags/'))
|| needs.optimize-ci.outputs.release
)
&& !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.outputs.skip == false
&& needs.optimize-ci.outputs.graphite-labels == false
needs: [optimize-ci]
runs-on: ubuntu-latest
steps:
Expand All @@ -182,13 +193,8 @@ jobs:

typecheck:
if: |
!(
contains(toJSON(github.event.commits.*.msg), 'skip:ci')
|| contains(github.event.pull_request.labels.*.name, 'skip:ci')
|| needs.optimize-ci.outputs.skip == 'true'
)
&& !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.outputs.graphite-labels == false
needs: [optimize-ci]
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -255,13 +261,8 @@ jobs:

test:
if: |
!(
contains(toJSON(github.event.commits.*.msg), 'skip:ci')
|| contains(github.event.pull_request.labels.*.name, 'skip:ci')
|| needs.optimize-ci.outputs.skip == 'true'
)
&& !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.outputs.graphite-labels == false
needs: [optimize-ci]
runs-on: [ubuntu-latest-8-cores]
steps:
Expand Down Expand Up @@ -327,8 +328,8 @@ jobs:


build-scies:
needs: [lint, typecheck, test, check-alembic-migrations]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
needs: [lint, typecheck, test, check-alembic-migrations, optimize-ci]
if: needs.optimize-ci.outputs.release
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -394,8 +395,8 @@ jobs:


build-wheels:
needs: [lint, typecheck, test, check-alembic-migrations]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
needs: [lint, typecheck, test, check-alembic-migrations, optimize-ci]
if: needs.optimize-ci.outputs.release
runs-on: ubuntu-22.04
steps:
- name: Check out the revision
Expand Down Expand Up @@ -461,14 +462,14 @@ jobs:


build-sbom:
needs: [lint, typecheck, test, check-alembic-migrations]
if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}
needs: [lint, typecheck, test, check-alembic-migrations, optimize-ci]
if: needs.optimize-ci.outputs.release
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/')
needs: [build-scies, build-wheels, build-sbom, optimize-ci]
if: needs.optimize-ci.outputs.release
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down Expand Up @@ -610,8 +611,8 @@ jobs:


build-conda-pack-for-windows:
needs: [make-final-release]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
needs: [make-final-release, optimize-ci]
if: needs.optimize-ci.outputs.release
runs-on: windows-latest
permissions:
contents: write
Expand Down
Loading