Skip to content

Commit 6b7f03e

Browse files
committed
CI optimizations
1 parent 7822c78 commit 6b7f03e

2 files changed

Lines changed: 28 additions & 15 deletions

File tree

.github/workflows/install-slips-dependencies.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
name: Install Slips Dependencies
22

33
on:
4-
# workflow_call make this workflow re-usable
54
workflow_call:
6-
# these are like variables to make the workflow more clean
7-
# we can pass these variable from another workflows if we want
85
inputs:
96
zeek-repo-url:
107
description: 'Zeek repository URL'
@@ -25,6 +22,8 @@ on:
2522
jobs:
2623
install-dependencies:
2724
runs-on: ubuntu-22.04
25+
outputs:
26+
dependencies_installed: ${{ steps.mark_installed.outputs.installed }}
2827
steps:
2928
- uses: actions/checkout@v4
3029
with:
@@ -62,3 +61,7 @@ jobs:
6261
curl -fsSL ${{ inputs.zeek-key-url }} | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/security_zeek.gpg
6362
sudo apt update && sudo apt install -y --no-install-recommends zeek
6463
sudo ln -s /opt/zeek/bin/zeek /usr/local/bin/bro
64+
65+
- name: Mark dependencies as installed
66+
id: mark_installed
67+
run: echo "installed=true" >> $GITHUB_OUTPUT

.github/workflows/unit-tests.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,16 @@ on:
66
- 'master'
77
- 'develop'
88

9-
109
jobs:
1110
# uses the common workflow that builds slips
1211
install-dependencies-using-reusable-workflow:
1312
uses: ./.github/workflows/install-slips-dependencies.yml
1413

1514
unit-tests:
1615
runs-on: ubuntu-22.04
17-
timeout-minutes: 1800
18-
# make this job depend on the first job
16+
timeout-minutes: 120
1917
needs: install-dependencies-using-reusable-workflow
2018

21-
# suppress tensorflow warnings
2219
env:
2320
TF_CPP_MIN_LOG_LEVEL: 3
2421
TF_ENABLE_ONEDNN_OPTS: 0
@@ -93,8 +90,12 @@ jobs:
9390
- uses: actions/checkout@v4
9491
with:
9592
ref: ${{ github.ref }}
96-
fetch-depth: ''
93+
fetch-depth: 0
9794

95+
- name: Set up Python
96+
uses: actions/setup-python@v5
97+
with:
98+
python-version: 3.10
9899

99100
- name: Restore APT cache
100101
id: apt-cache
@@ -106,20 +107,29 @@ jobs:
106107
key: apt-cache
107108

108109
- if: ${{ steps.apt-cache.outputs.cache-hit == 'true' }}
109-
name: Echo restored from cache
110+
name: Echo restored APT cache
110111
continue-on-error: true
111112
run: echo "Restored APT dependencies from cache successfully"
112113

113-
- name: Install Python dependencies (from cache if possible)
114-
run: |
115-
python3 -m pip install --upgrade pip
116-
python3 -m pip install -r install/requirements.txt
117-
118-
- name: Install apt dependencies (from cache if possible)
114+
- name: Install apt dependencies
119115
run: |
120116
sudo apt-get update
121117
sudo apt-get install -y $(cat install/apt_dependencies.txt)
122118
119+
- name: Restore Python dependencies
120+
id: python-cache
121+
uses: actions/cache@v4
122+
with:
123+
path: ~/.cache/pip
124+
key: ${{ runner.os }}-pip-${{ hashFiles('install/requirements.txt') }}
125+
126+
- if: ${{ steps.python-cache.outputs.cache-hit == 'true' }}
127+
name: Echo restored Python cache
128+
continue-on-error: true
129+
run: echo "Restored Python dependencies from cache successfully"
130+
131+
- name: Install Python dependencies
132+
run: python3 -m pip install -r install/requirements.txt
123133

124134
- name: Start redis server
125135
run: redis-server --daemonize yes

0 commit comments

Comments
 (0)