From e886f3742f9bfdc702e173c2afdaf189c0c238e0 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Thu, 21 Jul 2022 11:46:20 -0600 Subject: [PATCH 1/2] chore: standardize workflows --- .github/workflows/ci.yaml | 48 ------------------------------- .github/workflows/lint.yaml | 41 -------------------------- .github/workflows/lint.yml | 26 +++++++++++------ .github/workflows/test.yml | 57 ++++++++++++++++++++++++------------- 4 files changed, 56 insertions(+), 116 deletions(-) delete mode 100644 .github/workflows/ci.yaml delete mode 100644 .github/workflows/lint.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index 38cb2a9b..00000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,48 +0,0 @@ -name: CI - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - workflow_dispatch: - -jobs: - test: - concurrency: - group: ${{ github.head_ref || github.ref }} - cancel-in-progress: true - # Only run for internal PRs or after a merge - if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }} - runs-on: ubuntu-latest - strategy: - matrix: - # TODO - expand matrix once stable - python-version: [3.6] - steps: - - uses: actions/checkout@v3 - - name: Fetch and Diff PR with base from which it was cloned - if: ${{ github.event.pull_request.base.sha }} - run: | - git fetch origin master "${{ github.event.pull_request.base.sha }}" - git diff --diff-filter=ACM --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" > "${HOME}/changed_files.txt" - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pipenv - - name: Write test credentials - run: | - mkdir "${HOME}/secrets" - echo "${DEFAULT_CREDENTIALS}" > "${HOME}/secrets/default_credentials.json" - echo "${SERVICE_ACCOUNT_CREDENTIALS}" > "${HOME}/secrets/service_account.json" - echo "${CLIENT_ID_FILE}" > "${HOME}/secrets/client_id.json" - env: - DEFAULT_CREDENTIALS: ${{secrets.SNIPPETS_DEFAULT_CREDENTIALS}} - SERVICE_ACCOUNT_CREDENTIALS: ${{secrets.SNIPPETS_DELEGATED_ADMIN_SERVICE_ACCOUNT}} - CLIENT_ID_FILE: ${{secrets.SNIPPETS_CLIENT_ID_FILE}} - - name: Run tests - run: ./.github/scripts/test.sh diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml deleted file mode 100644 index 9a397403..00000000 --- a/.github/workflows/lint.yaml +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2021 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -name: Lint -on: - push: - branches: - - master - pull_request: - branches: - - master - workflow_dispatch: - -jobs: - lint: - concurrency: - group: ${{ github.head_ref || github.ref }} - cancel-in-progress: true - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3.0.0 - with: - # Full git history is needed to get a proper list of changed files within `super-linter` - fetch-depth: 0 - - uses: github/super-linter/slim@v4.9.0 - env: - ERROR_ON_MISSING_EXEC_BIT: true - VALIDATE_JSCPD: false - VALIDATE_PYTHON_BLACK: false - VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c5cb1be8..8e89655b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -# Copyright 2022 Google LLC +# Copyright 2021 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -11,14 +11,24 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - name: Lint -on: [push, pull_request] +on: [push, pull_request, workflow_dispatch] + jobs: lint: - runs-on: ubuntu-latest + concurrency: + group: ${{ github.head_ref || github.ref }} + cancel-in-progress: true + runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 - - run: | - echo "No lint checks"; - exit 1; + - uses: actions/checkout@v3.0.0 + with: + # Full git history is needed to get a proper list of changed files within `super-linter` + fetch-depth: 0 + - uses: github/super-linter/slim@v4.9.0 + env: + ERROR_ON_MISSING_EXEC_BIT: true + VALIDATE_JSCPD: false + VALIDATE_PYTHON_BLACK: false + VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index debf4655..bbeb9304 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,24 +1,43 @@ -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - name: Test -on: [push, pull_request] + +on: [push, pull_request, workflow_dispatch] + jobs: test: + concurrency: + group: ${{ github.head_ref || github.ref }} + cancel-in-progress: true + # Only run for internal PRs or after a merge + if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }} runs-on: ubuntu-latest + strategy: + matrix: + # TODO - expand matrix once stable + python-version: [3.6] steps: - - uses: actions/checkout@v2 - - run: | - echo "No tests"; - exit 1; + - uses: actions/checkout@v3 + - name: Fetch and Diff PR with base from which it was cloned + if: ${{ github.event.pull_request.base.sha }} + run: | + git fetch origin master "${{ github.event.pull_request.base.sha }}" + git diff --diff-filter=ACM --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" > "${HOME}/changed_files.txt" + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pipenv + - name: Write test credentials + run: | + mkdir "${HOME}/secrets" + echo "${DEFAULT_CREDENTIALS}" > "${HOME}/secrets/default_credentials.json" + echo "${SERVICE_ACCOUNT_CREDENTIALS}" > "${HOME}/secrets/service_account.json" + echo "${CLIENT_ID_FILE}" > "${HOME}/secrets/client_id.json" + env: + DEFAULT_CREDENTIALS: ${{secrets.SNIPPETS_DEFAULT_CREDENTIALS}} + SERVICE_ACCOUNT_CREDENTIALS: ${{secrets.SNIPPETS_DELEGATED_ADMIN_SERVICE_ACCOUNT}} + CLIENT_ID_FILE: ${{secrets.SNIPPETS_CLIENT_ID_FILE}} + - name: Run tests + run: ./.github/scripts/test.sh From 51878591d5f883897c4227a1fb6e4e3b466b3899 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Thu, 21 Jul 2022 12:02:24 -0600 Subject: [PATCH 2/2] test: aggregate matrix --- .github/workflows/test.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bbeb9304..6bf0b6d2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ name: Test on: [push, pull_request, workflow_dispatch] jobs: - test: + matrix: concurrency: group: ${{ github.head_ref || github.ref }} cancel-in-progress: true @@ -41,3 +41,8 @@ jobs: CLIENT_ID_FILE: ${{secrets.SNIPPETS_CLIENT_ID_FILE}} - name: Run tests run: ./.github/scripts/test.sh + test: + needs: [matrix] + runs-on: ubuntu-latest + steps: + - run: echo "Test matrix finished"