Skip to content

Commit e1597ea

Browse files
authored
chore: Create tests.yml (#766)
Initial conversion to Github Actions for CI
1 parent fd7f377 commit e1597ea

File tree

2 files changed

+332
-18
lines changed

2 files changed

+332
-18
lines changed

packages/gapic-generator/.github/sync-repo-settings.yaml

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,21 @@ branchProtectionRules:
55
- pattern: master
66
isAdminEnforced: true
77
requiredStatusCheckContexts:
8-
- 'ci/circleci: docs'
9-
- 'ci/circleci: mypy'
10-
- 'ci/circleci: showcase'
11-
- 'ci/circleci: showcase-alternative-templates'
12-
- 'ci/circleci: showcase-mtls'
13-
- 'ci/circleci: showcase-mtls-alternative-templates'
14-
- 'ci/circleci: showcase-mypy'
15-
- 'ci/circleci: showcase-mypy-alternative-templates'
16-
- 'ci/circleci: showcase-unit-3.6'
17-
- 'ci/circleci: showcase-unit-3.7'
18-
- 'ci/circleci: showcase-unit-3.8'
19-
- 'ci/circleci: showcase-unit-add-iam-methods'
20-
- 'ci/circleci: showcase-unit-alternative-templates-3.7'
21-
- 'ci/circleci: showcase-unit-alternative-templates-3.8'
22-
- 'ci/circleci: style-check'
23-
- 'ci/circleci: unit-3.6'
24-
- 'ci/circleci: unit-3.7'
25-
- 'ci/circleci: unit-3.8'
268
- 'cla/google'
279
- 'codecov/patch'
2810
- 'codecov/project'
2911
- 'conventionalcommits.org'
12+
- 'docs'
13+
- 'mypy'
14+
- 'showcase'
15+
- 'showcase-mtls'
16+
- 'showcase-unit'
17+
- 'showcase-unit-alternative-templates'
18+
- 'showcase-unit-add-iam-methods'
19+
- 'showcase-mypy'
20+
- 'showcase-mypy-alternative-templates'
21+
- 'unit'
22+
- 'style-check'
3023
requiredApprovingReviewCount: 1
3124
requiresCodeOwnerReviews: true
3225
requiresStrictStatusChecks: true
Lines changed: 321 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,321 @@
1+
name: Tests
2+
3+
# Controls when the action will run.
4+
on:
5+
pull_request:
6+
push:
7+
branches: [ $default-branch ]
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
jobs:
13+
docs:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Python 3.8
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: 3.8
21+
- name: Install nox.
22+
run: python -m pip install nox
23+
- name: Build the documentation.
24+
run: nox -s docs
25+
mypy:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v2
29+
- name: Set up Python 3.8
30+
uses: actions/setup-python@v2
31+
with:
32+
python-version: 3.8
33+
- name: Install nox.
34+
run: python -m pip install nox
35+
- name: Check type annotations.
36+
run: nox -s mypy
37+
# publish_image:
38+
# runs-on: ubuntu-latest
39+
# container: docker
40+
# steps:
41+
# - uses: actions/checkout@v2
42+
# - setup_remote_docker
43+
# - name: Build Docker image.
44+
# run: docker build . -t gcr.io/gapic-images/gapic-generator-python:latest
45+
# - name: Download curl
46+
# run: apk add --no-cache curl
47+
# - name: Download the GCR credential helper.
48+
# run: |
49+
# curl -fsSL https://github.com/GoogleCloudPlatform/docker-credential-gcr/releases/download/v1.5.0/docker-credential-gcr_linux_amd64-1.5.0.tar.gz \
50+
# | tar xz --to-stdout ./docker-credential-gcr \
51+
# > /usr/bin/docker-credential-gcr && chmod a+x /usr/bin/docker-credential-gcr
52+
# - name: Set up authentication to Google Container Registry.
53+
# run: |
54+
# echo ${GCLOUD_SERVICE_KEY} > ${GOOGLE_APPLICATION_CREDENTIALS}
55+
# docker-credential-gcr configure-docker
56+
# - name: Tag the Docker image and push it to Google Container Registry.
57+
# run: |
58+
# if [ -n "$CIRCLE_TAG" ]; then
59+
# export MAJOR=`echo $CIRCLE_TAG | awk -F '.' '{ print $1; }'`
60+
# export MINOR=`echo $CIRCLE_TAG | awk -F '.' '{ print $2; }'`
61+
# export PATCH=`echo $CIRCLE_TAG | awk -F '.' '{ print $3; }'`
62+
# docker tag gcr.io/gapic-images/gapic-generator-python:latest gcr.io/gapic-images/gapic-generator-python:$MAJOR.$MINOR.$PATCH
63+
# docker tag gcr.io/gapic-images/gapic-generator-python:latest gcr.io/gapic-images/gapic-generator-python:$MAJOR.$MINOR
64+
# docker tag gcr.io/gapic-images/gapic-generator-python:latest gcr.io/gapic-images/gapic-generator-python:$MAJOR
65+
# docker push gcr.io/gapic-images/gapic-generator-python:$MAJOR.$MINOR.$PATCH
66+
# docker push gcr.io/gapic-images/gapic-generator-python:$MAJOR.$MINOR
67+
# docker push gcr.io/gapic-images/gapic-generator-python:$MAJOR
68+
# fi
69+
# docker push gcr.io/gapic-images/gapic-generator-python:latest
70+
showcase:
71+
strategy:
72+
matrix:
73+
target: [showcase, showcase_alternative_templates]
74+
runs-on: ubuntu-latest
75+
steps:
76+
- uses: actions/checkout@v2
77+
- name: Set up Python 3.8
78+
uses: actions/setup-python@v2
79+
with:
80+
python-version: 3.8
81+
- name: Install system dependencies.
82+
run: |
83+
sudo apt-get update
84+
sudo apt-get install -y curl pandoc unzip gcc
85+
- name: Install showcase
86+
run: |
87+
sudo mkdir -p /usr/src/showcase
88+
sudo chown -R ${USER} /usr/src/
89+
curl --location https://github.com/googleapis/gapic-showcase/releases/download/v0.12.0/gapic-showcase-0.12.0-linux-amd64.tar.gz --output /usr/src/showcase/showcase-0.12.0-linux-amd64.tar.gz
90+
cd /usr/src/showcase/
91+
tar -xf showcase-*
92+
./gapic-showcase run &
93+
cd -
94+
- name: Install nox.
95+
run: python -m pip install nox
96+
- name: Install protoc 3.12.1.
97+
run: |
98+
sudo mkdir -p /usr/src/protoc/
99+
sudo chown -R ${USER} /usr/src/
100+
curl --location https://github.com/google/protobuf/releases/download/v3.12.1/protoc-3.12.1-linux-x86_64.zip --output /usr/src/protoc/protoc-3.12.1.zip
101+
cd /usr/src/protoc/
102+
unzip protoc-3.12.1.zip
103+
sudo ln -s /usr/src/protoc/bin/protoc /usr/local/bin/protoc
104+
- name: Run showcase tests.
105+
run: nox -s ${{ matrix.target }}
106+
showcase-mtls:
107+
strategy:
108+
matrix:
109+
target: [showcase_mtls, showcase_mtls_alternative_templates]
110+
runs-on: ubuntu-latest
111+
steps:
112+
- uses: actions/checkout@v2
113+
- name: Setup temp directory
114+
run: |
115+
sudo mkdir -p /tmp/workspace/tests/cert/
116+
sudo chown -R ${USER} /tmp/workspace/
117+
- name: Set up Python 3.8
118+
uses: actions/setup-python@v2
119+
with:
120+
python-version: 3.8
121+
- name: Copy mtls files
122+
run: cp tests/cert/mtls.* /tmp/workspace/tests/cert/
123+
- name: Install system dependencies.
124+
run: |
125+
sudo apt-get update
126+
sudo apt-get install -y curl pandoc unzip gcc
127+
- name: Install nox.
128+
run: python -m pip install nox
129+
- name: Install protoc 3.12.1.
130+
run: |
131+
sudo mkdir -p /usr/src/protoc/
132+
sudo chown -R ${USER} /usr/src
133+
curl --location https://github.com/google/protobuf/releases/download/v3.12.1/protoc-3.12.1-linux-x86_64.zip --output /usr/src/protoc/protoc-3.12.1.zip
134+
cd /usr/src/protoc/
135+
unzip protoc-3.12.1.zip
136+
sudo ln -s /usr/src/protoc/bin/protoc /usr/local/bin/protoc
137+
cd -
138+
- name: Run showcase tests.
139+
run: |
140+
sudo mkdir gapic_showcase
141+
sudo chown ${USER} gapic_showcase
142+
cd gapic_showcase
143+
curl -sSL https://github.com/googleapis/gapic-showcase/releases/download/v0.11.0/gapic-showcase-0.11.0-linux-amd64.tar.gz | tar xz
144+
./gapic-showcase run --mtls-ca-cert=/tmp/workspace/tests/cert/mtls.crt --mtls-cert=/tmp/workspace/tests/cert/mtls.crt --mtls-key=/tmp/workspace/tests/cert/mtls.key &
145+
showcase_pid=$!
146+
147+
cleanup() {
148+
echo "kill showcase server"
149+
kill $showcase_pid
150+
# Wait for the process to die, but don't report error from the kill.
151+
wait $showcase_pid || exit $exit_code
152+
}
153+
trap cleanup EXIT
154+
155+
cd ..
156+
nox -s ${{ matrix.target }}
157+
# TODO(yon-mg): add compute unit tests
158+
showcase-unit:
159+
strategy:
160+
matrix:
161+
python: [3.6, 3.7, 3.8, 3.9]
162+
runs-on: ubuntu-latest
163+
steps:
164+
- uses: actions/checkout@v2
165+
- name: Set up Python ${{ matrix.python }}
166+
uses: actions/setup-python@v2
167+
with:
168+
python-version: ${{ matrix.python }}
169+
- name: Install system dependencies.
170+
run: |
171+
sudo apt-get update
172+
sudo apt-get install -y curl pandoc unzip gcc
173+
- name: Install protoc 3.12.1.
174+
run: |
175+
sudo mkdir -p /usr/src/protoc/
176+
sudo chown -R ${USER} /usr/src/
177+
curl --location https://github.com/google/protobuf/releases/download/v3.12.1/protoc-3.12.1-linux-x86_64.zip --output /usr/src/protoc/protoc-3.12.1.zip
178+
cd /usr/src/protoc/
179+
unzip protoc-3.12.1.zip
180+
sudo ln -s /usr/src/protoc/bin/protoc /usr/local/bin/protoc
181+
- name: Install nox.
182+
run: python -m pip install nox
183+
- name: Run unit tests.
184+
run: nox -s showcase_unit-${{ matrix.python }}
185+
showcase-unit-alternative-templates:
186+
strategy:
187+
matrix:
188+
python: [3.7, 3.8, 3.9]
189+
runs-on: ubuntu-latest
190+
steps:
191+
- uses: actions/checkout@v2
192+
- name: Set up Python ${{ matrix.python }}
193+
uses: actions/setup-python@v2
194+
with:
195+
python-version: ${{ matrix.python }}
196+
- name: Install system dependencies.
197+
run: |
198+
sudo apt-get update
199+
sudo apt-get install -y curl pandoc unzip gcc
200+
- name: Install protoc 3.12.1.
201+
run: |
202+
sudo mkdir -p /usr/src/protoc/
203+
sudo chown -R ${USER} /usr/src/
204+
curl --location https://github.com/google/protobuf/releases/download/v3.12.1/protoc-3.12.1-linux-x86_64.zip --output /usr/src/protoc/protoc-3.12.1.zip
205+
cd /usr/src/protoc/
206+
unzip protoc-3.12.1.zip
207+
sudo ln -s /usr/src/protoc/bin/protoc /usr/local/bin/protoc
208+
- name: Install nox.
209+
run: python -m pip install nox
210+
- name: Run unit tests.
211+
run: nox -s showcase_unit_alternative_templates-${{ matrix.python }}
212+
showcase-unit-add-iam-methods:
213+
runs-on: ubuntu-latest
214+
steps:
215+
- uses: actions/checkout@v2
216+
- name: Set up Python 3.8
217+
uses: actions/setup-python@v2
218+
with:
219+
python-version: 3.8
220+
- name: Install system dependencies.
221+
run: |
222+
sudo apt-get update
223+
sudo apt-get install -y curl pandoc unzip gcc
224+
- name: Install protoc 3.12.1.
225+
run: |
226+
sudo mkdir -p /usr/src/protoc/
227+
sudo chown -R ${USER} /usr/src/
228+
curl --location https://github.com/google/protobuf/releases/download/v3.12.1/protoc-3.12.1-linux-x86_64.zip --output /usr/src/protoc/protoc-3.12.1.zip
229+
cd /usr/src/protoc/
230+
unzip protoc-3.12.1.zip
231+
sudo ln -s /usr/src/protoc/bin/protoc /usr/local/bin/protoc
232+
- name: Install nox.
233+
run: python -m pip install nox
234+
- name: Run unit tests.
235+
run: nox -s showcase_unit_add_iam_methods-3.8
236+
showcase-mypy:
237+
runs-on: ubuntu-latest
238+
steps:
239+
- uses: actions/checkout@v2
240+
- name: Set up Python 3.8
241+
uses: actions/setup-python@v2
242+
with:
243+
python-version: 3.8
244+
- name: Install system dependencies.
245+
run: |
246+
sudo apt-get update
247+
sudo apt-get install -y curl pandoc unzip gcc
248+
- name: Install protoc 3.12.1.
249+
run: |
250+
sudo mkdir -p /usr/src/protoc/
251+
sudo chown -R ${USER} /usr/src/
252+
curl --location https://github.com/google/protobuf/releases/download/v3.12.1/protoc-3.12.1-linux-x86_64.zip --output /usr/src/protoc/protoc-3.12.1.zip
253+
cd /usr/src/protoc/
254+
unzip protoc-3.12.1.zip
255+
sudo ln -s /usr/src/protoc/bin/protoc /usr/local/bin/protoc
256+
- name: Install nox.
257+
run: python -m pip install nox
258+
- name: Typecheck the generated output.
259+
run: nox -s showcase_mypy
260+
showcase-mypy-alternative-templates:
261+
runs-on: ubuntu-latest
262+
steps:
263+
- uses: actions/checkout@v2
264+
- name: Set up Python 3.8
265+
uses: actions/setup-python@v2
266+
with:
267+
python-version: 3.8
268+
- name: Install system dependencies.
269+
run: |
270+
sudo apt-get update
271+
sudo apt-get install -y curl pandoc unzip gcc
272+
- name: Install protoc 3.12.1.
273+
run: |
274+
sudo mkdir -p /usr/src/protoc/
275+
sudo chown -R ${USER} /usr/src/
276+
curl --location https://github.com/google/protobuf/releases/download/v3.12.1/protoc-3.12.1-linux-x86_64.zip --output /usr/src/protoc/protoc-3.12.1.zip
277+
cd /usr/src/protoc/
278+
unzip protoc-3.12.1.zip
279+
sudo ln -s /usr/src/protoc/bin/protoc /usr/local/bin/protoc
280+
- name: Install nox.
281+
run: python -m pip install nox
282+
- name: Typecheck the generated output.
283+
run: nox -s showcase_mypy_alternative_templates
284+
unit:
285+
strategy:
286+
matrix:
287+
python: [3.6, 3.7, 3.8, 3.9]
288+
runs-on: ubuntu-latest
289+
steps:
290+
- uses: actions/checkout@v2
291+
- name: Set up Python ${{ matrix.python }}
292+
uses: actions/setup-python@v2
293+
with:
294+
python-version: ${{ matrix.python }}
295+
- name: Install pandoc
296+
run: |
297+
sudo apt-get update
298+
sudo apt-get install -y pandoc gcc git
299+
- name: Install nox and codecov.
300+
run: |
301+
python -m pip install nox
302+
python -m pip install codecov
303+
- name: Run unit tests.
304+
run: nox -s unit-${{ matrix.python }}
305+
- name: Submit coverage data to codecov.
306+
run: codecov
307+
if: always()
308+
style-check:
309+
runs-on: ubuntu-latest
310+
steps:
311+
- uses: actions/checkout@v2
312+
- name: Set up Python 3.8
313+
uses: actions/setup-python@v2
314+
with:
315+
python-version: 3.8
316+
- name: Install autopep8
317+
run: |
318+
python -m pip install autopep8
319+
- name: Check diff
320+
run: |
321+
find gapic tests -name "*.py" | xargs autopep8 --in-place --exit-code

0 commit comments

Comments
 (0)