-
Notifications
You must be signed in to change notification settings - Fork 53
154 lines (150 loc) · 4.83 KB
/
verify_library_generation.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
on:
pull_request:
name: verify_library_generation
jobs:
should-run-library-generation-tests:
runs-on: ubuntu-22.04
outputs:
should_run: ${{ steps.get_changed_directories.outputs.should_run }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: get changed directories in the pull request
id: get_changed_directories
shell: bash
run: |
set -ex
# PRs that come from a fork need to be handled differently
if [[ ${head_repo_name} == ${base_repo} ]]; then
git checkout ${base_ref}
git checkout ${head_ref}
changed_directories="$(git diff --name-only ${base_ref} ${head_ref})"
else
git remote add fork ${head_repo_url}
git fetch fork # create a mapping of the fork
git checkout -b "${head_ref}" fork/${head_ref}
changed_directories="$(git diff --name-only "fork/${head_ref}" "origin/${base_ref}")"
fi
if [[ ${changed_directories} =~ "library_generation/" ]]; then
echo "should_run=true" >> $GITHUB_OUTPUT
else
echo "should_run=false" >> $GITHUB_OUTPUT
fi
env:
base_ref: ${{ github.event.pull_request.base.ref }}
head_ref: ${{ github.event.pull_request.head.ref }}
head_repo_url: ${{ github.event.pull_request.head.repo.html_url }}
head_repo_name: ${{ github.event.pull_request.head.repo.full_name }}
base_repo: ${{ github.repository }}
library-generation-integration-tests:
runs-on: ubuntu-22.04
needs: should-run-library-generation-tests
if: needs.should-run-library-generation-tests.outputs.should_run == 'true'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
- name: install pyenv
shell: bash
run: |
set -ex
curl https://pyenv.run | bash
# setup environment
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
echo "PYENV_ROOT=${PYENV_ROOT}" >> $GITHUB_ENV
echo "PATH=${PATH}" >> $GITHUB_ENV
set +ex
- name: install python dependencies
shell: bash
run: |
set -ex
pushd library_generation
pip install -r requirements.txt
pip install .
popd
- name: Run integration tests
shell: bash
run: |
set -x
python -m unittest library_generation/test/integration_tests.py
library-generation-unit-tests:
runs-on: ${{ matrix.os }}
needs: should-run-library-generation-tests
if: needs.should-run-library-generation-tests.outputs.should_run == 'true'
strategy:
matrix:
java: [ 8 ]
os: [ ubuntu-22.04, macos-12 ]
steps:
- uses: actions/checkout@v4
- name: install utils (macos)
if: matrix.os == 'macos-12'
shell: bash
run: |
brew update --preinstall
brew install coreutils
- uses: actions/setup-python@v5
with:
python-version: 3.11
- name: install python dependencies
shell: bash
run: |
set -ex
pushd library_generation
pip install -r requirements.txt
popd
- name: install synthtool
shell: bash
run: |
set -ex
mkdir -p /tmp/synthtool
pushd /tmp/synthtool
if [ ! -d "synthtool" ]; then
git clone https://github.com/googleapis/synthtool.git
fi
pushd "synthtool"
git reset --hard origin/no-java-templates
python3 -m pip install -e .
python3 -m pip install -r requirements.in
- name: Run shell unit tests
run: |
set -x
library_generation/test/generate_library_unit_tests.sh
- name: Run python unit tests
run: |
set -x
python -m unittest discover -s library_generation/test/ -p "*unit_tests.py"
library-generation-lint-shell:
runs-on: ubuntu-22.04
needs: should-run-library-generation-tests
if: needs.should-run-library-generation-tests.outputs.should_run == 'true'
steps:
- uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/[email protected]
with:
scandir: 'library_generation'
format: tty
severity: error
library-generation-lint-python:
runs-on: ubuntu-22.04
needs: should-run-library-generation-tests
if: needs.should-run-library-generation-tests.outputs.should_run == 'true'
steps:
- uses: actions/checkout@v4
- name: install python dependencies
shell: bash
run: |
set -ex
pushd library_generation
pip install -r requirements.txt
popd
- name: Lint
shell: bash
run: |
# exclude generated golden files
# exclude owlbot until further refaction
black --check library_generation --exclude "(library_generation/test/resources/goldens)"