Skip to content

Commit

Permalink
ci(PR): introduce new workflow PR
Browse files Browse the repository at this point in the history
  • Loading branch information
clearloop committed Jul 18, 2023
1 parent d3db8e5 commit 7be096c
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 8 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ on:
- cron: "0 3 * * *"
push:
branches: [master, vara-stage-1, vara-stage-2, vara-stage-3]
pull_request:
branches: [master, vara-stage-1, vara-stage-2, vara-stage-3]
types: [labeled, synchronize]

workflow_dispatch:

env:
Expand Down Expand Up @@ -44,6 +40,8 @@ jobs:

build:
uses: ./.github/workflows/build.yml
with:
macos: true

build-win-native:
if: ${{ github.ref == 'refs/heads/master' }}
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/PR.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: PR

on:
pull_request:
branches: [master, vara-stage-1, vara-stage-2, vara-stage-3]

env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
RUST_BACKTRACE: short
TERM: xterm-256color
BINARYEN_VERSION: version_111

jobs:
status:
runs-on: ubuntu-latest
outputs:
cache: ${{ steps.check-commit-message.outputs.cache }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Check Commit Message
id: check-commit-message
run: |
MESSAGE=$(git show -s --format=%s)
CACHE=true
if [[ $MESSAGE == *"[skip-cache]"* ]]; then
CACHE=false
fi
echo "cache: ${CACHE}"
echo "cache=${CACHE}" >> $GITHUB_OUTPUT
check:
needs: status
uses: ./.github/workflows/check.yml
with:
cache: ${{ needs.status.outputs.cache }}

build:
needs: status
uses: ./.github/workflows/build.yml
if: >-
contains(github.event.pull_request.labels.*.name, 'A0-pleasereview')
|| contains(github.event.pull_request.labels.*.name, 'A2-mergeoncegreen')
with:
cache: ${{ needs.status.outputs.cache }}
macos: contains(github.event.pull_request.labels.*.name, 'E2-forcemacos')
13 changes: 10 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: Build

on:
workflow_call:
inputs:
cache:
type: boolean
default: true
macos:
type: boolean
default: false

env:
CARGO_INCREMENTAL: 0
Expand Down Expand Up @@ -54,7 +61,7 @@ jobs:
./rust-covfix --version
- name: "Cache: Unpack"
# if: ${{ github.event_name == 'pull_request' && !contains(needs.check-commit-message.outputs.commit-message, '[skip-cache]') }}
if: ${{ inputs.cache }}
continue-on-error: true
run: |
tar -xf /cache/build_cargo_registry_${{ github.base_ref }}.tar -C /
Expand Down Expand Up @@ -255,7 +262,7 @@ jobs:
mv ./cargo-xwin ${CARGO_HOME:-~/.cargo}/bin/
- name: "Cache: Unpack"
# if: ${{ github.event_name == 'pull_request' && !contains(needs.check-commit-message.outputs.commit-message, '[skip-cache]') }}
if: ${{ inputs.cache }}
continue-on-error: true
run: |
tar -xf /cache/build_win_cross_cargo_registry_${{ github.base_ref }}.tar -C /
Expand Down Expand Up @@ -293,7 +300,7 @@ jobs:
mv /tmp/*.tar /cache/
macos-x86:
if: ${{ always() && (github.ref == 'refs/heads/master' || contains(github.event.pull_request.labels.*.name, 'E2-forcemacos')) }}
if: ${{ always() && inputs.macos }}
needs: linux
runs-on: macos-latest
env:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Check

on:
workflow_call:
inputs:
cache:
type: boolean
default: true

env:
CARGO_INCREMENTAL: 0
Expand Down Expand Up @@ -39,7 +43,7 @@ jobs:
sudo cp binaryen-$BINARYEN_VERSION/bin/wasm-opt /usr/bin/
- name: "Cache: Unpack"
# if: ${{ github.event_name == 'pull_request' && !contains(needs.check-commit-message.outputs.commit-message, '[skip-cache]') }}
if: ${{ github.event_name == 'pull_request' && !inputs.cache }}
continue-on-error: true
run: |
tar -xf /cache/check_cargo_registry_${{ github.base_ref }}.tar -C /
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Labels

on:
pull_request:
branches: [master, vara-stage-1, vara-stage-2, vara-stage-3]
types: [labeled]

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.11.0
with:
access_token: ${{ github.token }}

build:
uses: ./.github/workflows/build.yml
# TODO: dispatch this workflow with github action API
# for more conditions. for example, if the there is
# already a build check exist. (issue-2888)
if: >-
github.event.label.name == 'A0-pleasereview'
|| github.event.label.name == 'E2-forcemacos'
with:
macos: github.event.label.name == 'E2-forcemacos'

0 comments on commit 7be096c

Please sign in to comment.