|
1 | | -# Copyright 2022 Google LLC |
2 | | -# |
3 | | -# Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | -# you may not use this file except in compliance with the License. |
5 | | -# You may obtain a copy of the License at |
6 | | -# |
7 | | -# http://www.apache.org/licenses/LICENSE-2.0 |
8 | | -# |
9 | | -# Unless required by applicable law or agreed to in writing, software |
10 | | -# distributed under the License is distributed on an "AS IS" BASIS, |
11 | | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | -# See the License for the specific language governing permissions and |
13 | | -# limitations under the License. |
14 | | - |
15 | 1 | name: Test |
16 | | -on: [push, pull_request] |
| 2 | + |
| 3 | +on: [push, pull_request, workflow_dispatch] |
| 4 | + |
17 | 5 | jobs: |
| 6 | + matrix: |
| 7 | + concurrency: |
| 8 | + group: ${{ github.head_ref || github.ref }} |
| 9 | + cancel-in-progress: true |
| 10 | + # Only run for internal PRs or after a merge |
| 11 | + if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }} |
| 12 | + runs-on: ubuntu-latest |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + # TODO - expand matrix once stable |
| 16 | + python-version: [3.6] |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v3 |
| 19 | + - name: Fetch and Diff PR with base from which it was cloned |
| 20 | + if: ${{ github.event.pull_request.base.sha }} |
| 21 | + run: | |
| 22 | + git fetch origin master "${{ github.event.pull_request.base.sha }}" |
| 23 | + git diff --diff-filter=ACM --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" > "${HOME}/changed_files.txt" |
| 24 | + - name: Set up Python ${{ matrix.python-version }} |
| 25 | + uses: actions/setup-python@v2 |
| 26 | + with: |
| 27 | + python-version: ${{ matrix.python-version }} |
| 28 | + - name: Install dependencies |
| 29 | + run: | |
| 30 | + python -m pip install --upgrade pip |
| 31 | + pip install pipenv |
| 32 | + - name: Write test credentials |
| 33 | + run: | |
| 34 | + mkdir "${HOME}/secrets" |
| 35 | + echo "${DEFAULT_CREDENTIALS}" > "${HOME}/secrets/default_credentials.json" |
| 36 | + echo "${SERVICE_ACCOUNT_CREDENTIALS}" > "${HOME}/secrets/service_account.json" |
| 37 | + echo "${CLIENT_ID_FILE}" > "${HOME}/secrets/client_id.json" |
| 38 | + env: |
| 39 | + DEFAULT_CREDENTIALS: ${{secrets.SNIPPETS_DEFAULT_CREDENTIALS}} |
| 40 | + SERVICE_ACCOUNT_CREDENTIALS: ${{secrets.SNIPPETS_DELEGATED_ADMIN_SERVICE_ACCOUNT}} |
| 41 | + CLIENT_ID_FILE: ${{secrets.SNIPPETS_CLIENT_ID_FILE}} |
| 42 | + - name: Run tests |
| 43 | + run: ./.github/scripts/test.sh |
18 | 44 | test: |
| 45 | + needs: [matrix] |
19 | 46 | runs-on: ubuntu-latest |
20 | 47 | steps: |
21 | | - - uses: actions/checkout@v2 |
22 | | - - run: | |
23 | | - echo "No tests"; |
24 | | - exit 1; |
| 48 | + - run: echo "Test matrix finished" |
0 commit comments