bpo-40548: GitHub Action workflow: skip jobs on doc only PRs (GH-19983) · python/cpython@75d7257 (original) (raw)

Original file line number Diff line number Diff line change
@@ -16,9 +16,27 @@ on:
16 16 - 3.7
17 17
18 18 jobs:
19 +check_source:
20 +name: 'Check for source changes'
21 +runs-on: ubuntu-latest
22 +outputs:
23 +run_tests: ${{ steps.check.outputs.run_tests }}
24 +steps:
25 + - uses: actions/checkout@v2
26 + - name: Check for source changes
27 +id: check
28 +run: |
29 + if [ -z "GITHUB_BASE_REF" ]; then
30 + echo '::set-output name=run_tests::true'
31 + else
32 + git fetch origin $GITHUB_BASE_REF --depth=1
33 + git diff --name-only origin/$GITHUB_BASE_REF... | grep -qvE '(\.rst$
34 + fi
19 35 build_win32:
20 36 name: 'Windows (x86)'
21 37 runs-on: windows-latest
38 +needs: check_source
39 +if: needs.check_source.outputs.run_tests == 'true'
22 40 steps:
23 41 - uses: actions/checkout@v1
24 42 - name: Build CPython
@@ -31,6 +49,8 @@ jobs:
31 49 build_win_amd64:
32 50 name: 'Windows (x64)'
33 51 runs-on: windows-latest
52 +needs: check_source
53 +if: needs.check_source.outputs.run_tests == 'true'
34 54 steps:
35 55 - uses: actions/checkout@v1
36 56 - name: Build CPython
@@ -43,6 +63,8 @@ jobs:
43 63 build_macos:
44 64 name: 'macOS'
45 65 runs-on: macos-latest
66 +needs: check_source
67 +if: needs.check_source.outputs.run_tests == 'true'
46 68 steps:
47 69 - uses: actions/checkout@v1
48 70 - name: Configure CPython
@@ -57,6 +79,8 @@ jobs:
57 79 build_ubuntu:
58 80 name: 'Ubuntu'
59 81 runs-on: ubuntu-latest
82 +needs: check_source
83 +if: needs.check_source.outputs.run_tests == 'true'
60 84 env:
61 85 OPENSSL_VER: 1.1.1f
62 86 steps: