Skip to content

Commit c951993

Browse files
author
Justin Poehnelt
authored
chore: standardize workflows (#344)
* chore: standardize workflows * test: aggregate matrix
1 parent 41ec2f3 commit c951993

4 files changed

Lines changed: 61 additions & 116 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 0 additions & 48 deletions
This file was deleted.

.github/workflows/lint.yaml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 Google LLC
1+
# Copyright 2021 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -11,14 +11,24 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
1514
name: Lint
16-
on: [push, pull_request]
15+
on: [push, pull_request, workflow_dispatch]
16+
1717
jobs:
1818
lint:
19-
runs-on: ubuntu-latest
19+
concurrency:
20+
group: ${{ github.head_ref || github.ref }}
21+
cancel-in-progress: true
22+
runs-on: ubuntu-20.04
2023
steps:
21-
- uses: actions/checkout@v2
22-
- run: |
23-
echo "No lint checks";
24-
exit 1;
24+
- uses: actions/checkout@v3.0.0
25+
with:
26+
# Full git history is needed to get a proper list of changed files within `super-linter`
27+
fetch-depth: 0
28+
- uses: github/super-linter/slim@v4.9.0
29+
env:
30+
ERROR_ON_MISSING_EXEC_BIT: true
31+
VALIDATE_JSCPD: false
32+
VALIDATE_PYTHON_BLACK: false
33+
VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' }}
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,48 @@
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-
151
name: Test
16-
on: [push, pull_request]
2+
3+
on: [push, pull_request, workflow_dispatch]
4+
175
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
1844
test:
45+
needs: [matrix]
1946
runs-on: ubuntu-latest
2047
steps:
21-
- uses: actions/checkout@v2
22-
- run: |
23-
echo "No tests";
24-
exit 1;
48+
- run: echo "Test matrix finished"

0 commit comments

Comments
 (0)