|
| 1 | +name: Python Model Tests |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request_target: |
| 5 | + types: [labeled] |
| 6 | + |
| 7 | +permissions: |
| 8 | + id-token: write |
| 9 | + contents: read |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }}-${{ github.event_name }}-${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.ref || github.sha }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +defaults: |
| 16 | + run: |
| 17 | + shell: bash |
| 18 | + |
| 19 | +jobs: |
| 20 | + python-model-tests-pr: |
| 21 | + name: Python Model Tests - PR / python ${{ matrix.python-version }} |
| 22 | + if: contains(github.event.pull_request.labels.*.name, 'enable-functional-tests') |
| 23 | + |
| 24 | + runs-on: ubuntu-latest |
| 25 | + timeout-minutes: 45 |
| 26 | + |
| 27 | + strategy: |
| 28 | + fail-fast: false |
| 29 | + matrix: |
| 30 | + python-version: ["3.13"] |
| 31 | + |
| 32 | + env: |
| 33 | + TOXENV: "python-models" |
| 34 | + PYTEST_ADDOPTS: "-v --color=yes --csv python_model_results.csv -s" |
| 35 | + DBT_AWS_ACCOUNT: ${{ secrets.DBT_AWS_ACCOUNT }} |
| 36 | + DBT_GLUE_ROLE_ARN: ${{ secrets.DBT_GLUE_ROLE_ARN }} |
| 37 | + DBT_GLUE_REGION: ${{ secrets.DBT_GLUE_REGION }} |
| 38 | + |
| 39 | + steps: |
| 40 | + - name: Check out the repository |
| 41 | + uses: actions/checkout@v3 |
| 42 | + with: |
| 43 | + ref: ${{ github.event.pull_request.head.sha }} |
| 44 | + |
| 45 | + - name: Set up Python ${{ matrix.python-version }} |
| 46 | + uses: actions/setup-python@v4 |
| 47 | + with: |
| 48 | + python-version: ${{ matrix.python-version }} |
| 49 | + |
| 50 | + - name: Install python dependencies |
| 51 | + run: | |
| 52 | + sudo apt-get update |
| 53 | + sudo apt-get install libsasl2-dev |
| 54 | + python -m pip install --user --upgrade pip |
| 55 | + python -m pip --version |
| 56 | + python -m pip install tox |
| 57 | + tox --version |
| 58 | +
|
| 59 | + - name: Generate session name |
| 60 | + id: session |
| 61 | + run: | |
| 62 | + repo="${GITHUB_REPOSITORY#${GITHUB_REPOSITORY_OWNER}/}" |
| 63 | + echo "name=${repo}-python-models-pr-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" >> "${GITHUB_OUTPUT}" |
| 64 | +
|
| 65 | + - name: Configure AWS Credentials |
| 66 | + uses: aws-actions/configure-aws-credentials@v4 |
| 67 | + with: |
| 68 | + role-session-name: ${{ steps.session.outputs.name }} |
| 69 | + role-to-assume: arn:aws:iam::${{ secrets.DBT_AWS_ACCOUNT }}:role/dbt-glue |
| 70 | + aws-region: ${{ secrets.DBT_GLUE_REGION }} |
| 71 | + mask-aws-account-id: true |
| 72 | + |
| 73 | + - name: Run Python model tests |
| 74 | + run: | |
| 75 | + export DBT_S3_LOCATION=${{ secrets.DBT_S3_LOCATION }}/python-models-pr-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}/${{ matrix.python-version }} |
| 76 | + tox |
| 77 | +
|
| 78 | + - name: Get current date |
| 79 | + if: always() |
| 80 | + id: date |
| 81 | + run: echo "date=$(date +'%Y-%m-%dT%H_%M_%S')" >> $GITHUB_OUTPUT |
| 82 | + |
| 83 | + - uses: actions/upload-artifact@v4 |
| 84 | + if: always() |
| 85 | + with: |
| 86 | + name: python_model_results_pr_${{ matrix.python-version }}-${{ steps.date.outputs.date }}.csv |
| 87 | + path: python_model_results.csv |
| 88 | + overwrite: true |
0 commit comments