Skip to content

Commit d4a6615

Browse files
committed
feat(GHA): create composite action for setup
1 parent 7a9ca8f commit d4a6615

File tree

2 files changed

+43
-98
lines changed

2 files changed

+43
-98
lines changed

.github/actions/setup/action.yaml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: 'Setup OpenWPM env'
2+
description: 'Sets up conda and installs dependencies'
3+
runs:
4+
using: "composite"
5+
steps:
6+
# All of these steps are just setup
7+
- name: Setting MAMBA_PATH
8+
shell: bash
9+
run: echo "MAMBA_PATH=$HOME/mamba" >> $GITHUB_ENV
10+
- name: Setting OPENWPM_MAMBA_PATH
11+
shell: bash
12+
run: echo "OPENWPM_MAMBA_PATH=$MAMBA_PATH/envs/openwpm" >> $GITHUB_ENV
13+
# If the environment.yaml hasn't changed we just reuse the entire conda install
14+
- id: cache
15+
uses: actions/cache@v4
16+
env:
17+
cache-name: conda-cache
18+
with:
19+
path: ${{ env.MAMBA_PATH }}
20+
key: ${{ env.cache-name }}-${{ hashFiles('environment.yaml') }}
21+
22+
- name: Install conda
23+
shell: bash
24+
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
25+
run: $GITHUB_WORKSPACE/scripts/install-mamba.sh
26+
27+
- shell: bash
28+
run: echo "$MAMBA_PATH/bin" >> $GITHUB_PATH
29+
30+
- name: Install.sh (cache miss)
31+
shell: bash
32+
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
33+
run: $GITHUB_WORKSPACE/install.sh
34+
- name: Install.sh (cache hit)
35+
shell: bash
36+
if: ${{ steps.cache.outputs.cache-hit == 'true' }}
37+
run: $GITHUB_WORKSPACE/install.sh --skip-create
38+
- shell: bash
39+
run: echo "$OPENWPM_MAMBA_PATH/bin" >> $GITHUB_PATH
40+
# Now we have a working OpenWPM environment

.github/workflows/run-tests.yaml

+3-98
Original file line numberDiff line numberDiff line change
@@ -13,71 +13,15 @@ jobs:
1313
pre-commit:
1414
runs-on: ubuntu-latest
1515
steps:
16-
# All of these steps are just setup
1716
- uses: actions/checkout@v4
18-
- name: Setting MAMBA_PATH
19-
run: echo "MAMBA_PATH=$HOME/mamba" >> $GITHUB_ENV
20-
- name: Setting OPENWPM_MAMBA_PATH
21-
run: echo "OPENWPM_MAMBA_PATH=$MAMBA_PATH/envs/openwpm" >> $GITHUB_ENV
22-
# If the environment.yaml hasn't changed we just reuse the entire conda install
23-
- id: cache
24-
uses: actions/cache@v4
25-
env:
26-
cache-name: conda-cache
27-
with:
28-
path: ${{ env.MAMBA_PATH }}
29-
key: ${{ env.cache-name }}-${{ hashFiles('environment.yaml') }}
30-
31-
- name: Install conda
32-
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
33-
run: $GITHUB_WORKSPACE/scripts/install-mamba.sh
34-
35-
- run: echo "$MAMBA_PATH/bin" >> $GITHUB_PATH
36-
37-
- name: Install.sh (cache miss)
38-
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
39-
run: $GITHUB_WORKSPACE/install.sh
40-
- name: Install.sh (cache hit)
41-
if: ${{ steps.cache.outputs.cache-hit == 'true' }}
42-
run: $GITHUB_WORKSPACE/install.sh --skip-create
43-
- run: echo "$OPENWPM_MAMBA_PATH/bin" >> $GITHUB_PATH
44-
# Now we have a working OpenWPM environment
45-
17+
- uses: ./.github/actions/setup
4618
- run: pre-commit run --all
4719

4820
demo:
4921
runs-on: ubuntu-latest
5022
steps:
51-
# All of these steps are just setup
5223
- uses: actions/checkout@v4
53-
- name: Setting MAMBA_PATH
54-
run: echo "MAMBA_PATH=$HOME/mamba" >> $GITHUB_ENV
55-
- name: Setting OPENWPM_MAMBA_PATH
56-
run: echo "OPENWPM_MAMBA_PATH=$MAMBA_PATH/envs/openwpm" >> $GITHUB_ENV
57-
# If the environment.yaml hasn't changed we just reuse the entire conda install
58-
- id: cache
59-
uses: actions/cache@v4
60-
env:
61-
cache-name: conda-cache
62-
with:
63-
path: ${{ env.MAMBA_PATH }}
64-
key: ${{ env.cache-name }}-${{ hashFiles('environment.yaml') }}
65-
66-
- name: Install conda
67-
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
68-
run: $GITHUB_WORKSPACE/scripts/install-mamba.sh
69-
70-
- run: echo "$MAMBA_PATH/bin" >> $GITHUB_PATH
71-
72-
- name: Install.sh (cache miss)
73-
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
74-
run: $GITHUB_WORKSPACE/install.sh
75-
- name: Install.sh (cache hit)
76-
if: ${{ steps.cache.outputs.cache-hit == 'true' }}
77-
run: $GITHUB_WORKSPACE/install.sh --skip-create
78-
- run: echo "$OPENWPM_MAMBA_PATH/bin" >> $GITHUB_PATH
79-
# Now we have a working OpenWPM environment
80-
24+
- uses: ./.github/actions/setup
8125
- run: python demo.py --headless
8226
tests:
8327
runs-on: ubuntu-latest
@@ -95,47 +39,8 @@ jobs:
9539
]
9640
fail-fast: false
9741
steps:
98-
# All of these steps are just setup, maybe we should wrap them in an action
9942
- uses: actions/checkout@v4
100-
- name: Cache node modules
101-
uses: actions/cache@v4
102-
env:
103-
cache-name: cache-node-modules
104-
with:
105-
# npm cache files are stored in `~/.npm` on Linux/macOS
106-
path: ~/.npm
107-
key: ${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
108-
# Setting env variables that depend on $HOME
109-
- name: Setting MAMBA_PATH
110-
run: echo "MAMBA_PATH=$HOME/mamba" >> $GITHUB_ENV
111-
- name: Setting OPENWPM_MAMBA_PATH
112-
run: echo "OPENWPM_MAMBA_PATH=$MAMBA_PATH/envs/openwpm" >> $GITHUB_ENV
113-
114-
# If the environment.yaml hasn't changed we just reuse the entire conda install
115-
- id: conda-cache
116-
uses: actions/cache@v4
117-
env:
118-
cache-name: conda-cache
119-
with:
120-
path: ${{ env.MAMBA_PATH }}
121-
key: ${{ env.cache-name }}-${{ hashFiles('environment.yaml') }}
122-
123-
- name: Install conda
124-
if: ${{ steps.conda-cache.outputs.cache-hit != 'true' }}
125-
run: $GITHUB_WORKSPACE/scripts/install-mamba.sh
126-
127-
- run: echo "$MAMBA_PATH/bin" >> $GITHUB_PATH
128-
129-
- name: Install.sh (cache miss)
130-
if: ${{ steps.conda-cache.outputs.cache-hit != 'true' }}
131-
run: $GITHUB_WORKSPACE/install.sh
132-
- name: Install.sh (cache hit)
133-
if: ${{ steps.conda-cache.outputs.cache-hit == 'true' }}
134-
run: $GITHUB_WORKSPACE/install.sh --skip-create
135-
136-
- run: echo "$OPENWPM_MAMBA_PATH/bin" >> $GITHUB_PATH
137-
# Now we have a working OpenWPM environment
138-
43+
- uses: ./.github/actions/setup
13944
- run: ./scripts/ci.sh
14045
env:
14146
DISPLAY: ":99.0"

0 commit comments

Comments
 (0)