Skip to content

Commit 0435f61

Browse files
committed
simplifying dependency setup
1 parent 5fc9837 commit 0435f61

File tree

4 files changed

+108
-99
lines changed

4 files changed

+108
-99
lines changed

.github/workflows/main.yml

Lines changed: 102 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: CI
33
on: [push, pull_request]
44

55
env:
6-
CACHE_SEED: 1
6+
PYTHON_VERSION: 3.8.2
77
NODE_VERSION: 14.4.0
88

99
jobs:
@@ -26,84 +26,70 @@ jobs:
2626

2727
- uses: actions/setup-python@v2
2828
with:
29-
python-version: 3.8
29+
python-version: ${{ env.PYTHON_VERSION }}
3030

3131
- name: Cache pip dependencies
3232
uses: actions/cache@v2
3333
env:
34-
cache-name: cache-pip-tests-warehouse-p
34+
cache-name: warehouse-cache-pip
3535
with:
36-
path: ./.cache/pip
37-
key: ${{ runner.os }}-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('requirements.txt') }}
36+
path: ~/.cache/pip
37+
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('requirements.txt') }}
3838
restore-keys: |
39-
${{ runner.os }}-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-
40-
${{ runner.os }}-${{ env.CACHE_SEED }}-${{ github.job }}-
41-
${{ runner.os }}-${{ env.CACHE_SEED }}-
39+
${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-
40+
${{ runner.os }}-${{ github.job }}-
4241
${{ runner.os }}-
4342
4443
- name: Cache node version manager
4544
uses: actions/cache@v2
4645
env:
47-
cache-name: cache-nvm-dh
46+
cache-name: warehouse-cache-nvm
4847
with:
4948
path: ~/.nvm/versions/
50-
key: ${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
49+
key: ${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
5150
restore-keys: |
52-
${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-
53-
${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-
54-
${{ runner.os }}-build-${{ env.CACHE_SEED }}-
51+
${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-
52+
${{ runner.os }}-build-${{ github.job }}-
5553
${{ runner.os }}-build-
5654
${{ runner.os }}-
5755
5856
- name: Cache node modules
5957
uses: actions/cache@v2
6058
env:
61-
cache-name: cache-npm-modules-dh
59+
cache-name: warehouse-cache-npm-modules
6260
with:
6361
path: |
6462
~/.npm
6563
**/node_modules
66-
key: ${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
64+
key: ${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
6765
restore-keys: |
68-
${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-
69-
${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-
70-
${{ runner.os }}-build-${{ env.CACHE_SEED }}-
66+
${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-
67+
${{ runner.os }}-build-${{ github.job }}-
7168
${{ runner.os }}-build-
7269
${{ runner.os }}-
7370
71+
- uses: actions/setup-node@v1
72+
with:
73+
node-version: ${{ env.NODE_VERSION }}
74+
7475
- name: Install dependencies
7576
run: sudo apt -y install libcurl4-openssl-dev libssl-dev pkg-config
7677

7778
- name: Install pip requirements
7879
run: |
79-
mkdir ./.cache && mkdir ./.cache/pip
80-
chown -R $(whoami) ./.cache/pip
81-
pip install -U pip setuptools wheel --cache-dir ./.cache/pip
82-
pip install -r requirements/main.txt --cache-dir ./.cache/pip
83-
pip install -r requirements/tests.txt --cache-dir ./.cache/pip
84-
pip install -r requirements/deploy.txt --cache-dir ./.cache/pip
80+
pip install -U pip setuptools wheel
81+
pip install -r requirements/main.txt
82+
pip install -r requirements/tests.txt
83+
pip install -r requirements/deploy.txt
8584
8685
- name: Setup node
8786
run: |
88-
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
89-
export NVM_DIR="$HOME/.nvm"
90-
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
91-
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
92-
nvm install $NODE_VERSION
9387
npm i -g npm
9488
npm install -g gulp-cli
9589
npm ci
9690
9791
- name: Run tests
98-
run: |
99-
python -m coverage run -m pytest --strict --postgresql-host localhost
100-
python -m coverage html
101-
python -m coverage report -m --fail-under 100
102-
env:
103-
# The hostname used to communicate with the PostgreSQL service container
104-
POSTGRES_HOST: localhost
105-
# The default PostgreSQL port
106-
POSTGRES_PORT: 5432
92+
run: bin/tests
10793

10894
lint:
10995
runs-on: ubuntu-latest
@@ -113,12 +99,42 @@ jobs:
11399

114100
- uses: actions/setup-python@v2
115101
with:
116-
python-version: 3.8
102+
python-version: ${{ env.PYTHON_VERSION }}
117103

118-
- name: Lint
104+
- name: Cache pip dependencies
105+
uses: actions/cache@v2
106+
env:
107+
cache-name: warehouse-cache-pip
108+
with:
109+
path: ~/.cache/pip
110+
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('requirements.txt') }}
111+
restore-keys: |
112+
${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-
113+
${{ runner.os }}-${{ github.job }}-
114+
${{ runner.os }}-
115+
116+
- name: Cache node modules
117+
uses: actions/cache@v2
118+
env:
119+
cache-name: warehouse-cache-node-modules
120+
with:
121+
path: |
122+
~/.npm
123+
**/node_modules
124+
key: ${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
125+
restore-keys: |
126+
${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-
127+
${{ runner.os }}-build-${{ github.job }}-
128+
${{ runner.os }}-build-
129+
${{ runner.os }}-
130+
131+
- name: Dependency setup
119132
run: |
133+
npm install eslint --save-dev
120134
sudo apt-get update && sudo apt-get install make
121-
make lint ACTIONS=true
135+
136+
- name: Lint
137+
run: make lint ACTIONS=true
122138

123139
docs:
124140
runs-on: ubuntu-latest
@@ -128,7 +144,7 @@ jobs:
128144

129145
- uses: actions/setup-python@v2
130146
with:
131-
python-version: 3.8
147+
python-version: ${{ env.PYTHON_VERSION }}
132148

133149
- name: Documentation
134150
run: |
@@ -143,26 +159,20 @@ jobs:
143159

144160
- uses: actions/setup-python@v2
145161
with:
146-
python-version: 3.8
162+
python-version: ${{ env.PYTHON_VERSION }}
147163

148164
- name: Cache pip dependencies
149165
uses: actions/cache@v2
150166
env:
151-
cache-name: cache-pip-deps-warehouse-p
167+
cache-name: warehouse-cache-pip
152168
with:
153169
path: ~/.cache/pip
154-
key: ${{ runner.os }}-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('requirements.txt') }}
170+
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('requirements.txt') }}
155171
restore-keys: |
156-
${{ runner.os }}-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-
157-
${{ runner.os }}-${{ env.CACHE_SEED }}-${{ github.job }}-
158-
${{ runner.os }}-${{ env.CACHE_SEED }}-
172+
${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-
173+
${{ runner.os }}-${{ github.job }}-
159174
${{ runner.os }}-
160175
161-
- name: Set cache permissions
162-
run: |
163-
mkdir ~/.cache && mkdir ~/.cache/pip
164-
chown -R $(whoami) ~/.cache/pip
165-
166176
- name: Check dependencies
167177
run: |
168178
sudo apt -y install libcurl4-openssl-dev libssl-dev pkg-config
@@ -185,47 +195,51 @@ jobs:
185195

186196
- uses: actions/setup-python@v2
187197
with:
188-
python-version: 3.8
198+
python-version: ${{ env.PYTHON_VERSION }}
189199

190200
- name: Check translations
191201
run: make translations
192202

193-
static-lint:
194-
runs-on: ubuntu-latest
195-
steps:
196-
- name: Check out repository
197-
uses: actions/checkout@v2
198-
199-
- name: Static Lint Check
200-
run: |
201-
npm install eslint --save-dev
202-
./node_modules/.bin/eslint 'warehouse/static/js/**' '**.js' 'tests/frontend/**' --ignore-pattern 'warehouse/static/js/vendor/**'
203-
./node_modules/.bin/sass-lint --verbose
204-
205203
static-tests:
206204
runs-on: ubuntu-latest
207205
steps:
208206
- name: Check out repository
209207
uses: actions/checkout@v2
210208

209+
- name: Cache node version manager
210+
uses: actions/cache@v2
211+
env:
212+
cache-name: warehouse-cache-nvm
213+
with:
214+
path: ~/.nvm/versions/
215+
key: ${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
216+
restore-keys: |
217+
${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-
218+
${{ runner.os }}-build-${{ github.job }}-
219+
${{ runner.os }}-build-
220+
${{ runner.os }}-
221+
211222
- name: Cache node modules
212223
uses: actions/cache@v2
213224
env:
214-
cache-name: cache-node-modules-static-dh
225+
cache-name: warehouse-cache-npm-modules-static
215226
with:
216227
path: |
217228
~/.npm
218229
**/node_modules
219-
key: ${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
230+
key: ${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
220231
restore-keys: |
221-
${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-
222-
${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-
223-
${{ runner.os }}-build-${{ env.CACHE_SEED }}-
232+
${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-
233+
${{ runner.os }}-build-${{ github.job }}-
224234
${{ runner.os }}-build-
225235
${{ runner.os }}-
226236
227-
- name: Dependency Setup
228-
run: npm install -D babel
237+
- uses: actions/setup-node@v1
238+
with:
239+
node-version: ${{ env.NODE_VERSION }}
240+
241+
- name: Node dependency setup
242+
run: npm ci
229243

230244
- name: Static Tests
231245
run: bin/static_tests
@@ -239,35 +253,37 @@ jobs:
239253
- name: Cache node version manager
240254
uses: actions/cache@v2
241255
env:
242-
cache-name: cache-nvm-pipeline-dh
256+
cache-name: warehouse-cache-nvm
243257
with:
244258
path: ~/.nvm/versions/
245-
key: ${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
259+
key: ${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
246260
restore-keys: |
247-
${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-
248-
${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-
249-
${{ runner.os }}-build-${{ env.CACHE_SEED }}-
261+
${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-
262+
${{ runner.os }}-build-${{ github.job }}-
250263
${{ runner.os }}-build-
251264
${{ runner.os }}-
252265
253266
- name: Cache node modules
254267
uses: actions/cache@v2
255268
env:
256-
cache-name: cache-node-modules-static-dh
269+
cache-name: warehouse-cache-npm-modules
257270
with:
258271
path: |
259272
~/.npm
260273
**/node_modules
261-
key: ${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
274+
key: ${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
262275
restore-keys: |
263-
${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-
264-
${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-
265-
${{ runner.os }}-build-${{ env.CACHE_SEED }}-
276+
${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-
277+
${{ runner.os }}-build-${{ github.job }}-
266278
${{ runner.os }}-build-
267279
${{ runner.os }}-
268280
269-
- name: Dependency Setup
270-
run: npm install -D babel
281+
- uses: actions/setup-node@v1
282+
with:
283+
node-version: ${{ env.NODE_VERSION }}
284+
285+
- name: Node dependency setup
286+
run: npm ci
271287

272288
- name: Static Pipeline Check
273-
run: bin/static_pipeline # this periodically fails for no reason, just rerun the job if needed
289+
run: bin/static_pipeline

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ lint: .state/env/pyvenv.cfg
112112
# TODO: Figure out a solution to https://github.com/deezer/template-remover/issues/1
113113
# so we can remove extra_whitespace from below.
114114
$(BINDIR)/html_lint.py --printfilename --disable=optional_tag,names,protocol,extra_whitespace,concerns_separation,boolean_attribute `find ./warehouse/templates -path ./warehouse/templates/legacy -prune -o -name '*.html' -print`
115-
ifneq ($(TRAVIS), false)
116-
# We're on Travis, so we can lint static files locally
115+
ifneq ($(filter false,$(TRAVIS) $(ACTIONS)),)
116+
# We're either on Travis or GitHub Actions, so we can lint static files locally
117117
./node_modules/.bin/eslint 'warehouse/static/js/**' '**.js' 'tests/frontend/**' --ignore-pattern 'warehouse/static/js/vendor/**'
118118
./node_modules/.bin/sass-lint --verbose
119-
else ifneq ($(ACTIONS), true)
119+
else
120120
# We're not on Travis or GitHub Actions, so we should lint static files inside the static container
121121
docker-compose run --rm static ./node_modules/.bin/eslint 'warehouse/static/js/**' '**.js' 'tests/frontend/**' --ignore-pattern 'warehouse/static/js/vendor/**'
122122
docker-compose run --rm static ./node_modules/.bin/sass-lint --verbose

bin/tests

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if [ $ATTEMPTS -eq 5 ]; then
2929
exit 1
3030
fi
3131

32-
# Print all the followng commands
32+
# Print all the following commands
3333
set -x
3434

3535
# Actually run our tests.

tests/conftest.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,10 @@ def database(request):
127127
pg_host = config.get("host")
128128
pg_port = config.get("port") or os.environ.get("PGPORT", 5432)
129129
pg_user = config.get("user")
130-
pg_pass = config.get("password")
131130
pg_db = config.get("db", "tests")
132131
pg_version = config.get("version", 10.1)
133132

134-
janitor = DatabaseJanitor(pg_user, pg_host, pg_port, pg_db, pg_version, pg_pass)
133+
janitor = DatabaseJanitor(pg_user, pg_host, pg_port, pg_db, pg_version)
135134

136135
# In case the database already exists, possibly due to an aborted test run,
137136
# attempt to drop it before creating
@@ -145,13 +144,7 @@ def database(request):
145144
def drop_database():
146145
janitor.drop()
147146

148-
pass_field = ""
149-
if pg_pass:
150-
pass_field = f":{pg_pass}"
151-
152-
return "postgresql://{}{}@{}:{}/{}".format(
153-
pg_user, pass_field, pg_host, pg_port, pg_db
154-
)
147+
return "postgresql://{}@{}:{}/{}".format(pg_user, pg_host, pg_port, pg_db)
155148

156149

157150
class MockManifestCacheBuster(ManifestCacheBuster):

0 commit comments

Comments
 (0)