diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml index 7a8148cea6dff..307fc33585478 100644 --- a/.github/workflows/presubmit.yml +++ b/.github/workflows/presubmit.yml @@ -20,10 +20,41 @@ jobs: python misc/ci_check_pr_title.py "$PR_TITLE" env: PR_TITLE: ${{ github.event.pull_request.title }} + check_files: + name: Check files + outputs: + run_job: ${{ steps.check_files.outputs.run_job }} + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 2 + + - name: check modified files + id: check_files + run: | + 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" + break + else + echo "::set-output name=run_job::true" + fi + done < files.txt check_code_format: name: Check Code Format runs-on: ubuntu-latest + needs: check_files # This job will be required to pass before merging to master branch. steps: - uses: actions/checkout@v2 @@ -34,6 +65,9 @@ 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 @@ -49,10 +83,16 @@ 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 @@ -61,6 +101,9 @@ jobs: - name: Pylint run: | + if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then + exit 0 + fi # Make sure pylint doesn't regress pylint python/taichi/ --disable=all --enable=C0121,C0415 if [ $? -eq 0 ] @@ -75,12 +118,16 @@ jobs: check_clang_tidy: name: Check clang-tidy runs-on: ubuntu-latest + needs: check_files steps: - uses: actions/checkout@v2 with: submodules: "recursive" - 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 @@ -88,6 +135,9 @@ jobs: CR_PAT: ${{ secrets.GITHUB_TOKEN }} - name: Run clang-tidy run: | + 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 @@ -98,7 +148,7 @@ jobs: build_and_test_cpu_required: # This job will be required to pass before merging to master branch. name: Required Build and Test (CPU) - needs: check_code_format + needs: [check_code_format, check_files] timeout-minutes: 60 strategy: matrix: @@ -116,6 +166,9 @@ 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 @@ -124,6 +177,9 @@ 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" # Docker cp preserves the ownership in the host machine. However, the user in the host machine won't be recognized @@ -138,6 +194,9 @@ 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 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/ @@ -149,7 +208,7 @@ jobs: build_and_test_cpu_linux: name: Build and Test linux (CPU) - needs: build_and_test_cpu_required + needs: [build_and_test_cpu_required, check_files] timeout-minutes: 60 strategy: matrix: @@ -171,6 +230,9 @@ 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 @@ -179,6 +241,9 @@ 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/ @@ -191,6 +256,9 @@ 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 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/ @@ -202,7 +270,7 @@ jobs: build_and_test_cpu_mac: name: Build and Test macos (CPU) - needs: build_and_test_cpu_required + needs: [build_and_test_cpu_required, check_files] timeout-minutes: 60 strategy: matrix: @@ -222,12 +290,20 @@ jobs: python-version: ${{ matrix.python }} - name: Download Pre-Built LLVM 10.0.0 - run: python misc/ci_download.py + 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: .github/workflows/scripts/unix_build.sh + 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 }} CXX: clang++ @@ -238,13 +314,17 @@ jobs: # limit-access-to-actor: true - name: Test - run: .github/workflows/scripts/unix_test.sh + 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 }} build_and_test_gpu_linux: name: Build and Test (GPU) - needs: check_code_format + needs: [check_code_format, check_files] runs-on: [self-hosted, cuda, vulkan, cn] timeout-minutes: 60 steps: @@ -254,6 +334,9 @@ 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/ @@ -267,6 +350,9 @@ 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 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/ @@ -279,11 +365,14 @@ 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 + needs: [check_code_format, check_files] runs-on: windows-latest timeout-minutes: 90 steps: @@ -305,6 +394,9 @@ jobs: - name: Download And Install Vulkan shell: powershell run: | + if ( "${{needs.check_files.outputs.run_job}}" -eq "false" ) { + exit 0 + } Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/1.2.189.0/windows/VulkanSDK-1.2.189.0-Installer.exe" -OutFile VulkanSDK.exe $installer = Start-Process -FilePath VulkanSDK.exe -Wait -PassThru -ArgumentList @("/S"); $installer.WaitForExit(); @@ -312,6 +404,9 @@ jobs: - name: Build shell: powershell run: | + if ( "${{needs.check_files.outputs.run_job}}" -eq "false" ) { + exit 0 + } $env:Path += ";C:/VulkanSDK/1.2.189.0/Bin" cd C:\ Remove-item alias:curl @@ -339,6 +434,9 @@ jobs: - 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 python -c "import taichi" python examples/algorithm/laplace.py @@ -350,7 +448,7 @@ jobs: build_and_test_m1: name: Build and Test (Apple M1) - needs: check_code_format + needs: [check_code_format, check_files] timeout-minutes: 60 strategy: matrix: @@ -369,6 +467,9 @@ 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: @@ -377,6 +478,9 @@ 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