From 34c2213e76b387a5c7231b23916af71130951888 Mon Sep 17 00:00:00 2001 From: FrankLeeeee Date: Thu, 26 Jan 2023 15:50:43 +0800 Subject: [PATCH] [workflow] fixed changed file detection --- .github/workflows/auto_example_check.yml | 17 +++++++++++++++++ .github/workflows/build.yml | 11 +++++++++++ .github/workflows/pre_commit.yml | 14 ++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/.github/workflows/auto_example_check.yml b/.github/workflows/auto_example_check.yml index f88b6858e003..6939db2f2844 100644 --- a/.github/workflows/auto_example_check.yml +++ b/.github/workflows/auto_example_check.yml @@ -25,9 +25,21 @@ jobs: with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} + + - name: Locate base commit + id: locate-base-sha + run: | + curBranch=$(git rev-parse --abbrev-ref HEAD) + commonCommit=$(git merge-base origin/main $curBranch) + echo $commonCommit + echo "baseSHA=$commonCommit" >> $GITHUB_OUTPUT + - name: Get all changed example files id: changed-files uses: tj-actions/changed-files@v35 + with: + base_sha: ${{ steps.locate-base-sha.outputs.baseSHA }} + - name: setup matrix id: setup-matrix run: | @@ -67,9 +79,11 @@ jobs: timeout-minutes: 10 steps: - uses: actions/checkout@v3 + - name: Install Colossal-AI run: | pip install -v . + - name: Test the example run: | example_dir=${{ matrix.directory }} @@ -91,6 +105,7 @@ jobs: steps: - name: 📚 Checkout uses: actions/checkout@v3 + - name: setup matrix id: setup-matrix run: | @@ -115,9 +130,11 @@ jobs: steps: - name: 📚 Checkout uses: actions/checkout@v3 + - name: Install Colossal-AI run: | pip install -v . + - name: Traverse all files run: | example_dir=${{ matrix.diretory }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 30b932729019..8f334d599124 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,14 +21,25 @@ jobs: with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} + + - name: Locate base commit + id: locate-base-sha + run: | + curBranch=$(git rev-parse --abbrev-ref HEAD) + commonCommit=$(git merge-base origin/main $curBranch) + echo $commonCommit + echo "baseSHA=$commonCommit" >> $GITHUB_OUTPUT + - name: Find the changed files id: find-changed-files uses: tj-actions/changed-files@v35 with: + base_sha: ${{ steps.locate-base-sha.outputs.baseSHA }} files: | op_builder/** colossalai/kernel/** setup.py + - name: List changed files run: | for file in ${{ steps.find-changed-files.outputs.all_changed_files }}; do diff --git a/.github/workflows/pre_commit.yml b/.github/workflows/pre_commit.yml index 113f50ee0569..3e71be2fc611 100644 --- a/.github/workflows/pre_commit.yml +++ b/.github/workflows/pre_commit.yml @@ -12,9 +12,23 @@ jobs: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} + # the PR branch and the hpcaitech/colossal-ai main branch + # must share a common commit, we need to locate that commit, + # which is the commit checked-out or forked when the PR branch is created + # such that we can look for files changed since that commit + - name: Locate base commit + id: locate-base-sha + run: | + curBranch=$(git rev-parse --abbrev-ref HEAD) + commonCommit=$(git merge-base origin/main $curBranch) + echo $commonCommit + echo "baseSHA=$commonCommit" >> $GITHUB_OUTPUT + - name: Find the changed files id: find-changed-files uses: tj-actions/changed-files@v35 + with: + base_sha: ${{ steps.locate-base-sha.outputs.baseSHA }} - name: List all changed files run: |