Skip to content

Commit

Permalink
Merge pull request #118 from 01-ai/fancy/improve_ci
Browse files Browse the repository at this point in the history
Split CI into separate jobs
  • Loading branch information
shiyue-loop authored Nov 14, 2023
2 parents 2cbbc97 + 7688884 commit 7fef28e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 34 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/basic_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Basic Check

on:
push:
branches:
- main
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
basic-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install linting libraries
run: pip install autoflake isort black
- name: Autoflake
run: |
output="$(autoflake . --remove-all-unused-imports --remove-unused-variables --expand-star-imports --ignore-init-module-imports -r)"
if [[ -n $output ]]
then
printf "%s\n" "$output"
exit 1
else
exit 0
fi
- name: Isort
run: isort . --profile black --check-only --diff
- name: Black
run: black . --diff --color --check
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: CI
name: Build Docker Image

on:
push:
branches:
- main
pull_request:
pull_request_target:
branches:
- main

Expand All @@ -13,29 +13,18 @@ concurrency:
cancel-in-progress: true

jobs:
basic-check:
authorize:
environment:
${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository && 'external' || 'internal' }}
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.read_version.outputs.value }}
steps:
- run: true

build-docker-image:
needs: authorize
runs-on: public
steps:
- uses: actions/checkout@v3
- name: Checkout Actions
uses: actions/checkout@v3
with:
repository: 01-ai/actions
token: ${{ secrets.PAT_TO_CLONE_ACTIONS }}
path: actions
ref: main
- name: Basic check
uses: ./actions/lint
# https://github.com/actions/checkout/issues/692#issuecomment-1502203573
- name: Checkout Actions
uses: actions/checkout@v3
with:
repository: 01-ai/actions
token: ${{ secrets.PAT_TO_CLONE_ACTIONS }}
path: actions
ref: main
# try to create a tag
- uses: SebRollen/[email protected]
id: read_version
Expand All @@ -47,16 +36,7 @@ jobs:
if: (github.ref_name == github.event.repository.default_branch) && !contains(steps.read_version.outputs.value, '-')
with:
tag: ${{ steps.read_version.outputs.value }}

build-and-push:
runs-on:
- public
needs: basic-check
outputs:
primary_tag: ${{ steps.build-and-push.outputs.primary_tag }}
matrix: ${{ steps.build-and-push.outputs.matrix }}
steps:
- uses: actions/checkout@v3
# build & push docker image
- name: Checkout Actions
uses: actions/checkout@v3
with:
Expand All @@ -74,6 +54,6 @@ jobs:
with:
registry: ${{ secrets.DEFAULT_REGISTRY }}
namespace: ci
tags: ${{ needs.basic-check.outputs.tag }}
tags: ${{ steps.read_version.outputs.value }}
username: ${{ secrets.DEFAULT_REGISTRY_USER }}
password: ${{ secrets.DEFAULT_REGISTRY_PASSWORD }}
password: ${{ secrets.DEFAULT_REGISTRY_PASSWORD }}

0 comments on commit 7fef28e

Please sign in to comment.