Skip to content

Commit b82e5c3

Browse files
authored
ci: introduce cache for unit tests, build and UI tests steps (#408)
* ci: introduce cache for unit test job as a start * ci: use cache for build and UI tests as well * ci: use direct path to the poetry.lock
1 parent 2ed4ea4 commit b82e5c3

File tree

1 file changed

+41
-16
lines changed

1 file changed

+41
-16
lines changed

.github/workflows/build-test-release.yaml

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ concurrency:
1212
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
1313
cancel-in-progress: true
1414

15+
env:
16+
PYTHON_VERSION: "3.7"
17+
POETRY_VERSION: "1.5.1"
18+
1519
jobs:
1620
meta:
1721
runs-on: ubuntu-latest
@@ -54,7 +58,7 @@ jobs:
5458
- uses: actions/checkout@v4
5559
- uses: actions/setup-python@v4
5660
with:
57-
python-version: "3.7"
61+
python-version: ${{ env.PYTHON_VERSION }}
5862
- uses: pre-commit/[email protected]
5963

6064
semgrep:
@@ -73,12 +77,19 @@ jobs:
7377
- uses: actions/checkout@v4
7478
- uses: actions/setup-python@v4
7579
with:
76-
python-version: "3.7"
77-
- run: |
78-
curl -sSL https://install.python-poetry.org | python3 - --version 1.5.1
80+
python-version: ${{ env.PYTHON_VERSION }}
7981
- run: |
80-
poetry install
81-
poetry run pytest -v tests/unit
82+
curl -sSL https://install.python-poetry.org | python3 - --version ${{ env.POETRY_VERSION }}
83+
- id: cache-poetry
84+
uses: actions/cache@v3
85+
with:
86+
path: ~/.cache/pypoetry
87+
key: poetry-${{ runner.os }}-${{ hashFiles('poetry.lock') }}
88+
restore-keys: |
89+
poetry-${{ runner.os }}-
90+
- run: poetry install
91+
if: ${{ steps.cache-poetry.outputs.cache-hit != 'true' }}
92+
- run: poetry run pytest -v tests/unit
8293

8394
build:
8495
name: build
@@ -94,11 +105,18 @@ jobs:
94105
persist-credentials: false
95106
- uses: actions/setup-python@v4
96107
with:
97-
python-version: 3.7
98-
- run: curl -sSL https://install.python-poetry.org | python3 - --version 1.5.1
99-
- run: |
100-
poetry install
101-
poetry build
108+
python-version: ${{ env.PYTHON_VERSION }}
109+
- run: curl -sSL https://install.python-poetry.org | python3 - --version ${{ env.POETRY_VERSION }}
110+
- id: cache-poetry
111+
uses: actions/cache@v3
112+
with:
113+
path: ~/.cache/pypoetry
114+
key: poetry-${{ runner.os }}-${{ hashFiles('poetry.lock') }}
115+
restore-keys: |
116+
poetry-${{ runner.os }}-
117+
- run: poetry install
118+
if: ${{ steps.cache-poetry.outputs.cache-hit != 'true' }}
119+
- run: poetry build
102120
- run: |
103121
poetry run ucc-gen build \
104122
--source=tests/testdata/Splunk_TA_UCCExample/package \
@@ -124,7 +142,6 @@ jobs:
124142
checks: write
125143
strategy:
126144
fail-fast: false
127-
max-parallel: 8
128145
matrix:
129146
splunk: ${{ fromJson(needs.meta.outputs.matrix_supportedSplunk) }}
130147
browser: ["chrome", "firefox"]
@@ -142,13 +159,21 @@ jobs:
142159
- uses: actions/checkout@v4
143160
- uses: actions/setup-python@v4
144161
with:
145-
python-version: "3.7"
162+
python-version: ${{ env.PYTHON_VERSION }}
146163
- uses: actions/download-artifact@v3
147164
with:
148165
name: output
149166
path: output/
150-
- run: curl -sSL https://install.python-poetry.org | python3 - --version 1.5.1
167+
- run: curl -sSL https://install.python-poetry.org | python3 - --version ${{ env.POETRY_VERSION }}
168+
- id: cache-poetry
169+
uses: actions/cache@v3
170+
with:
171+
path: ~/.cache/pypoetry
172+
key: poetry-${{ runner.os }}-${{ hashFiles('poetry.lock') }}
173+
restore-keys: |
174+
poetry-${{ runner.os }}-
151175
- run: poetry install
176+
if: ${{ steps.cache-poetry.outputs.cache-hit != 'true' }}
152177
- name: Link chromedriver and geckodriver
153178
# Use installed chromedriver https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md
154179
run: |
@@ -186,8 +211,8 @@ jobs:
186211
persist-credentials: false
187212
- uses: actions/setup-python@v4
188213
with:
189-
python-version: "3.7"
190-
- run: curl -sSL https://install.python-poetry.org | python3 - --version 1.5.1
214+
python-version: ${{ env.PYTHON_VERSION }}
215+
- run: curl -sSL https://install.python-poetry.org | python3 - --version ${{ env.POETRY_VERSION }}
191216
- id: semantic
192217
uses: splunk/[email protected]
193218
with:

0 commit comments

Comments
 (0)