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] Fix skipping presubmit checks #3569

Merged
merged 1 commit into from
Nov 21, 2021
Merged
Changes from all 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
99 changes: 31 additions & 68 deletions .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,38 @@ jobs:
echo "=============== list modified files ==============="
git diff --name-only @^

echo "========== check paths of modified files =========="
git diff --name-only @^ > files.txt
while IFS= read -r file
do
echo $file
if [[ $file == docs/* ]]; then
echo "This modified file is not under the 'docs' folder."
echo "::set-output name=run_job::false"
chore_files=( LICENSE CONTRIBUTING.md README.md netlify.toml )
chore_dirs=( docs )
run_job=false

for file in $(git diff --name-only @^); do
is_chore=false

for chore_file in ${chore_files[*]}; do
[[ ${file} == ${chore_file} ]] && is_chore=true && break
done

for chore_dir in ${chore_dirs[*]}; do
[[ ${file} == ${chore_dir}/* ]] && is_chore=true && break
done

if ! ${is_chore}; then
run_job=true
break
else
echo "::set-output name=run_job::true"
fi
done < files.txt
done

if ${run_job}; then
echo "::set-output name=run_job::true"
else
echo "::set-output name=run_job::false"
fi

check_code_format:
name: Check Code Format
runs-on: ubuntu-latest
needs: check_files
if: needs.check_files.outputs.run_job == 'true'
# This job will be required to pass before merging to master branch.
steps:
- uses: actions/checkout@v2
Expand All @@ -49,9 +63,6 @@ jobs:

- name: Setup git & clang-format
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
git config user.email "taichigardener@gmail.com"
git config user.name "Taichi Gardener"
git checkout -b _fake_squash
Expand All @@ -67,16 +78,10 @@ jobs:

- name: Install requirements
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
python3 -m pip install --user -r requirements_dev.txt

- name: Check code format
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
python3 misc/code_format.py
git checkout -b _enforced_format
git commit -am "enforce code format" || true
Expand All @@ -87,6 +92,7 @@ jobs:
name: Check Static Analyzer
runs-on: ubuntu-latest
needs: check_files
if: needs.check_files.outputs.run_job == 'true'
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -99,9 +105,6 @@ jobs:

- name: Pylint
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
python3 -m pip install --user pylint
# Make sure pylint doesn't regress
pylint python/taichi/ --disable=all --enable=$(python scripts/generate_pylint_tags.py)
Expand All @@ -116,15 +119,9 @@ jobs:

- name: clang-tidy
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-ghcrio
echo $CR_PAT | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker pull ghcr.io/taichi-dev/taichidev-cpu-ubuntu18.04:v0.1.0
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
docker run -id --user dev --name check_clang_tidy ghcr.io/taichi-dev/taichidev-cpu-ubuntu18.04:v0.1.0 /bin/bash
tar -cf - ../${{ github.event.repository.name }} --mode u=+rwx,g=+rwx,o=+rwx --owner dev --group dev | docker cp - check_clang_tidy:/home/dev/
docker exec --user root check_clang_tidy apt install -y clang-tidy-10
Expand All @@ -136,6 +133,7 @@ jobs:
build_and_test_cpu_linux:
name: Build and Test linux (CPU)
needs: [check_code_format, check_files]
if: needs.check_files.outputs.run_job == 'true'
timeout-minutes: 60
strategy:
matrix:
Expand All @@ -159,9 +157,6 @@ jobs:

- name: Get docker images
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-ghcrio
echo $CR_PAT | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker pull ghcr.io/taichi-dev/taichidev-cpu-ubuntu18.04:v0.1.0
Expand All @@ -170,9 +165,6 @@ jobs:

- name: Build
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
mkdir -m777 wheel
docker create -v `pwd`/wheel:/wheel --user dev --name taichi_build ghcr.io/taichi-dev/taichidev-cpu-ubuntu18.04:v0.1.0 /home/dev/taichi/.github/workflows/scripts/unix_docker_build.sh $PY $GPU_BUILD $PROJECT_NAME "$CI_SETUP_CMAKE_ARGS"
tar -cf - ../${{ github.event.repository.name }} --mode u=+rwx,g=+rwx,o=+rwx --owner dev --group dev | docker cp - taichi_build:/home/dev/
Expand All @@ -185,9 +177,6 @@ jobs:

- name: Test
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
docker create --user dev --name taichi_test ghcr.io/taichi-dev/taichidev-cpu-ubuntu18.04:v0.1.0 /home/dev/unix_docker_test.sh $PY $GPU_TEST $TI_WANTED_ARCHS
docker cp .github/workflows/scripts/unix_docker_test.sh taichi_test:/home/dev/unix_docker_test.sh
docker cp wheel/*.whl taichi_test:/home/dev/
Expand All @@ -201,6 +190,7 @@ jobs:
build_and_test_cpu_mac:
name: Build and Test macos (CPU)
needs: [check_code_format, check_files]
if: needs.check_files.outputs.run_job == 'true'
timeout-minutes: 60
strategy:
matrix:
Expand All @@ -222,18 +212,12 @@ jobs:

- name: Download Pre-Built LLVM 10.0.0
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
python misc/ci_download.py
env:
CI_PLATFORM: ${{ matrix.os }}

- name: Build & Install
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
.github/workflows/scripts/unix_build.sh
env:
CI_SETUP_CMAKE_ARGS: -DTI_WITH_OPENGL:BOOL=OFF -DTI_WITH_CC:BOOL=${{ matrix.with_cc }} -DTI_WITH_VULKAN:BOOL=OFF -DTI_BUILD_TESTS:BOOL=${{ matrix.with_cpp_tests }}
Expand All @@ -246,9 +230,6 @@ jobs:

- name: Test
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
.github/workflows/scripts/unix_test.sh
env:
RUN_CPP_TESTS: ${{ matrix.with_cpp_tests }}
Expand All @@ -258,6 +239,7 @@ jobs:
name: Build and Test (GPU)
needs: [check_code_format, check_files]
runs-on: [self-hosted, cuda, vulkan, cn]
if: needs.check_files.outputs.run_job == 'true'
timeout-minutes: 60
steps:
- uses: actions/checkout@v2
Expand All @@ -266,9 +248,6 @@ jobs:

- name: Build & Install
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
mkdir -m777 wheel
docker create -v `pwd`/wheel:/wheel --user dev --name taichi_build --gpus all -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix registry.taichigraphics.com/taichidev-ubuntu18.04:v0.1.1 /home/dev/taichi/.github/workflows/scripts/unix_docker_build.sh $PY $GPU_BUILD $PROJECT_NAME "$CI_SETUP_CMAKE_ARGS"
tar -cf - ../${{ github.event.repository.name }} --mode u=+rwx,g=+rwx,o=+rwx --owner dev --group dev | docker cp - taichi_build:/home/dev/
Expand All @@ -282,9 +261,6 @@ jobs:

- name: Test
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
docker create --user dev --name taichi_test --gpus all -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix registry.taichigraphics.com/taichidev-ubuntu18.04:v0.1.1 /home/dev/unix_docker_test.sh $PY $GPU_TEST $TI_WANTED_ARCHS
docker cp .github/workflows/scripts/unix_docker_test.sh taichi_test:/home/dev/unix_docker_test.sh
docker cp wheel/*.whl taichi_test:/home/dev/
Expand All @@ -298,14 +274,12 @@ jobs:
- name: clean docker container
if: always()
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
docker rm taichi_build taichi_test -f

build_and_test_windows:
name: Build and Test (Windows)
needs: [check_code_format, check_files]
if: needs.check_files.outputs.run_job == 'true'
runs-on: windows-latest
timeout-minutes: 90
steps:
Expand All @@ -323,17 +297,11 @@ jobs:
- name: Build
shell: powershell
run: |
if ( "${{needs.check_files.outputs.run_job}}" -eq "false" ) {
exit 0
}
.\.github\workflows\scripts\win_build.ps1 -installVulkan -install -libsDir C:\

- name: Test
shell: powershell
run: |
if ( "${{needs.check_files.outputs.run_job}}" -eq "false" ) {
exit 0
}
$env:PATH = ";C:\taichi_llvm\bin;C:\taichi_clang\bin;" + $env:PATH
. venv\Scripts\activate.ps1
python -c "import taichi"
Expand All @@ -349,6 +317,7 @@ jobs:
build_and_test_m1:
name: Build and Test (Apple M1)
needs: [check_code_format, check_files]
if: needs.check_files.outputs.run_job == 'true'
timeout-minutes: 60
strategy:
matrix:
Expand All @@ -367,9 +336,6 @@ jobs:

- name: Build
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
rm -rf $HOME/Library/Python/3.8/lib/python/site-packages/taichi
.github/workflows/scripts/unix_build.sh
env:
Expand All @@ -378,9 +344,6 @@ jobs:

- name: Test
run: |
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
exit 0
fi
export PATH=$PATH:$HOME/Library/Python/3.8/bin
python3 -m pip install -r requirements_test.txt
python3 examples/algorithm/laplace.py
Expand Down