Skip to content

Commit 4d39e9a

Browse files
committed
simplifying dependency setup
1 parent 5fc9837 commit 4d39e9a

File tree

4 files changed

+107
-95
lines changed

4 files changed

+107
-95
lines changed

.github/workflows/main.yml

Lines changed: 101 additions & 82 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,70 +26,64 @@ 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
@@ -99,11 +93,6 @@ jobs:
9993
python -m coverage run -m pytest --strict --postgresql-host localhost
10094
python -m coverage html
10195
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
10796
10897
lint:
10998
runs-on: ubuntu-latest
@@ -113,12 +102,42 @@ jobs:
113102

114103
- uses: actions/setup-python@v2
115104
with:
116-
python-version: 3.8
105+
python-version: ${{ env.PYTHON_VERSION }}
117106

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

123142
docs:
124143
runs-on: ubuntu-latest
@@ -128,7 +147,7 @@ jobs:
128147

129148
- uses: actions/setup-python@v2
130149
with:
131-
python-version: 3.8
150+
python-version: ${{ env.PYTHON_VERSION }}
132151

133152
- name: Documentation
134153
run: |
@@ -143,26 +162,20 @@ jobs:
143162

144163
- uses: actions/setup-python@v2
145164
with:
146-
python-version: 3.8
165+
python-version: ${{ env.PYTHON_VERSION }}
147166

148167
- name: Cache pip dependencies
149168
uses: actions/cache@v2
150169
env:
151-
cache-name: cache-pip-deps-warehouse-p
170+
cache-name: warehouse-cache-pip
152171
with:
153172
path: ~/.cache/pip
154-
key: ${{ runner.os }}-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('requirements.txt') }}
173+
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('requirements.txt') }}
155174
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 }}-
175+
${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-
176+
${{ runner.os }}-${{ github.job }}-
159177
${{ runner.os }}-
160178
161-
- name: Set cache permissions
162-
run: |
163-
mkdir ~/.cache && mkdir ~/.cache/pip
164-
chown -R $(whoami) ~/.cache/pip
165-
166179
- name: Check dependencies
167180
run: |
168181
sudo apt -y install libcurl4-openssl-dev libssl-dev pkg-config
@@ -185,47 +198,51 @@ jobs:
185198

186199
- uses: actions/setup-python@v2
187200
with:
188-
python-version: 3.8
201+
python-version: ${{ env.PYTHON_VERSION }}
189202

190203
- name: Check translations
191204
run: make translations
192205

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-
205206
static-tests:
206207
runs-on: ubuntu-latest
207208
steps:
208209
- name: Check out repository
209210
uses: actions/checkout@v2
210211

212+
- name: Cache node version manager
213+
uses: actions/cache@v2
214+
env:
215+
cache-name: warehouse-cache-nvm
216+
with:
217+
path: ~/.nvm/versions/
218+
key: ${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
219+
restore-keys: |
220+
${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-
221+
${{ runner.os }}-build-${{ github.job }}-
222+
${{ runner.os }}-build-
223+
${{ runner.os }}-
224+
211225
- name: Cache node modules
212226
uses: actions/cache@v2
213227
env:
214-
cache-name: cache-node-modules-static-dh
228+
cache-name: warehouse-cache-npm-modules-static
215229
with:
216230
path: |
217231
~/.npm
218232
**/node_modules
219-
key: ${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
233+
key: ${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
220234
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 }}-
235+
${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-
236+
${{ runner.os }}-build-${{ github.job }}-
224237
${{ runner.os }}-build-
225238
${{ runner.os }}-
226239
227-
- name: Dependency Setup
228-
run: npm install -D babel
240+
- uses: actions/setup-node@v1
241+
with:
242+
node-version: ${{ env.NODE_VERSION }}
243+
244+
- name: Node dependency setup
245+
run: npm ci
229246

230247
- name: Static Tests
231248
run: bin/static_tests
@@ -239,35 +256,37 @@ jobs:
239256
- name: Cache node version manager
240257
uses: actions/cache@v2
241258
env:
242-
cache-name: cache-nvm-pipeline-dh
259+
cache-name: warehouse-cache-nvm
243260
with:
244261
path: ~/.nvm/versions/
245-
key: ${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
262+
key: ${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
246263
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 }}-
264+
${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-
265+
${{ runner.os }}-build-${{ github.job }}-
250266
${{ runner.os }}-build-
251267
${{ runner.os }}-
252268
253269
- name: Cache node modules
254270
uses: actions/cache@v2
255271
env:
256-
cache-name: cache-node-modules-static-dh
272+
cache-name: warehouse-cache-npm-modules
257273
with:
258274
path: |
259275
~/.npm
260276
**/node_modules
261-
key: ${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
277+
key: ${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
262278
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 }}-
279+
${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-
280+
${{ runner.os }}-build-${{ github.job }}-
266281
${{ runner.os }}-build-
267282
${{ runner.os }}-
268283
269-
- name: Dependency Setup
270-
run: npm install -D babel
284+
- uses: actions/setup-node@v1
285+
with:
286+
node-version: ${{ env.NODE_VERSION }}
287+
288+
- name: Node dependency setup
289+
run: npm ci
271290

272291
- name: Static Pipeline Check
273-
run: bin/static_pipeline # this periodically fails for no reason, just rerun the job if needed
292+
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)