|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +name: PostCommit Python Auto |
| 19 | + |
| 20 | +on: |
| 21 | + schedule: |
| 22 | + - cron: '30 5/6 * * *' |
| 23 | + pull_request: |
| 24 | + branches: ['master'] |
| 25 | + workflow_dispatch: |
| 26 | + |
| 27 | +# This allows a subsequently queued workflow run to interrupt previous runs |
| 28 | +concurrency: |
| 29 | + group: '${{ github.workflow }} @ ${{ github.event.issue.number || github.sha || github.head_ref || github.ref }}-${{ github.event.schedule || github.event.comment.id || github.event.sender.login }}' |
| 30 | + cancel-in-progress: true |
| 31 | + |
| 32 | +#Setting explicit permissions for the action to avoid the default permissions which are `write-all` in case of pull_request_target event |
| 33 | +permissions: |
| 34 | + actions: write |
| 35 | + pull-requests: write |
| 36 | + checks: write |
| 37 | + contents: read |
| 38 | + deployments: read |
| 39 | + id-token: none |
| 40 | + issues: write |
| 41 | + discussions: read |
| 42 | + packages: read |
| 43 | + pages: read |
| 44 | + repository-projects: read |
| 45 | + security-events: read |
| 46 | + statuses: read |
| 47 | + |
| 48 | +env: |
| 49 | + DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} |
| 50 | + GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }} |
| 51 | + GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }} |
| 52 | + ALLOYDB_PASSWORD: ${{ secrets.ALLOYDB_PASSWORD }} |
| 53 | + |
| 54 | +jobs: |
| 55 | + beam_PostCommit_Python: |
| 56 | + name: ${{ matrix.job_name }} (${{ matrix.job_phrase }} ${{ matrix.python_version }}) |
| 57 | + runs-on: |
| 58 | + - [self-hosted, ubuntu-20.04, highmem22] |
| 59 | + - ubuntu-latest |
| 60 | + timeout-minutes: 240 |
| 61 | + strategy: |
| 62 | + fail-fast: false |
| 63 | + matrix: |
| 64 | + job_name: [beam_PostCommit_Python] |
| 65 | + job_phrase: [Run Python PostCommit] |
| 66 | + python_version: ['3.9', '3.10', '3.11', '3.12'] |
| 67 | + if: | |
| 68 | + github.event_name == 'workflow_dispatch' || |
| 69 | + github.event_name == 'pull_request_target' || |
| 70 | + (github.event_name == 'schedule' && github.repository == 'apache/beam') || |
| 71 | + startswith(github.event.comment.body, 'Run Python PostCommit 3.') |
| 72 | + steps: |
| 73 | + - uses: actions/checkout@v4 |
| 74 | + - name: Setup repository |
| 75 | + uses: ./.github/actions/setup-action |
| 76 | + with: |
| 77 | + comment_phrase: ${{ matrix.job_phrase }} ${{ matrix.python_version }} |
| 78 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 79 | + github_job: ${{ matrix.job_name }} (${{ matrix.job_phrase }} ${{ matrix.python_version }}) |
| 80 | + - name: Setup environment |
| 81 | + uses: ./.github/actions/setup-environment-action |
| 82 | + with: |
| 83 | + java-version: | |
| 84 | + 21 |
| 85 | + 11 |
| 86 | + python-version: ${{ matrix.python_version }} |
| 87 | + - name: Install docker compose |
| 88 | + run: | |
| 89 | + sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose |
| 90 | + sudo chmod +x /usr/local/bin/docker-compose |
| 91 | + - name: Set PY_VER_CLEAN |
| 92 | + id: set_py_ver_clean |
| 93 | + run: | |
| 94 | + PY_VER=${{ matrix.python_version }} |
| 95 | + PY_VER_CLEAN=${PY_VER//.} |
| 96 | + echo "py_ver_clean=$PY_VER_CLEAN" >> $GITHUB_OUTPUT |
| 97 | + - name: run PostCommit Python ${{ matrix.python_version }} script |
| 98 | + uses: ./.github/actions/gradle-command-self-hosted-action |
| 99 | + with: |
| 100 | + gradle-command: :python${{steps.set_py_ver_clean.outputs.py_ver_clean}}PostCommit |
| 101 | + arguments: | |
| 102 | + -Pjava21Home=$JAVA_HOME_21_X64 \ |
| 103 | + -PuseWheelDistribution \ |
| 104 | + # Conditionally add -Pposargs based on the runner type. |
| 105 | + -Pposargs="${{ |
| 106 | + contains(matrix.runner_os, 'self-hosted') && |
| 107 | + '-m ''not require_non_self_hosted''' || |
| 108 | + '-m ''require_non_self_hosted''' |
| 109 | + }}" \ |
| 110 | + -PpythonVersion=${{ matrix.python_version }} |
| 111 | + env: |
| 112 | + CLOUDSDK_CONFIG: ${{ env.KUBELET_GCLOUD_CONFIG_PATH}} |
| 113 | + - name: Archive Python Test Results |
| 114 | + uses: actions/upload-artifact@v4 |
| 115 | + if: failure() |
| 116 | + with: |
| 117 | + name: Python ${{ matrix.python_version }} Test Results |
| 118 | + path: '**/pytest*.xml' |
| 119 | + - name: Publish Python Test Results |
| 120 | + uses: EnricoMi/publish-unit-test-result-action@v2 |
| 121 | + if: always() |
| 122 | + with: |
| 123 | + commit: '${{ env.prsha || env.GITHUB_SHA }}' |
| 124 | + comment_mode: ${{ github.event_name == 'issue_comment' && 'always' || 'off' }} |
| 125 | + files: '**/pytest*.xml' |
| 126 | + large_files: true |
0 commit comments