Skip to content

Commit 19619d2

Browse files
committed
simplifying dependency setup
1 parent 5fc9837 commit 19619d2

File tree

4 files changed

+103
-105
lines changed

4 files changed

+103
-105
lines changed

.github/workflows/main.yml

Lines changed: 97 additions & 92 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,48 +26,45 @@ 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
@@ -76,34 +73,12 @@ jobs:
7673

7774
- name: Install pip requirements
7875
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
85-
86-
- name: Setup node
87-
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
93-
npm i -g npm
94-
npm install -g gulp-cli
95-
npm ci
76+
pip install -U pip setuptools wheel
77+
pip install -r requirements/main.txt
78+
pip install -r requirements/tests.txt
9679
9780
- 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
81+
run: bin/tests --postgresql-host localhost
10782

10883
lint:
10984
runs-on: ubuntu-latest
@@ -113,12 +88,42 @@ jobs:
11388

11489
- uses: actions/setup-python@v2
11590
with:
116-
python-version: 3.8
91+
python-version: ${{ env.PYTHON_VERSION }}
11792

118-
- name: Lint
93+
- name: Cache pip dependencies
94+
uses: actions/cache@v2
95+
env:
96+
cache-name: warehouse-cache-pip
97+
with:
98+
path: ~/.cache/pip
99+
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('requirements.txt') }}
100+
restore-keys: |
101+
${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-
102+
${{ runner.os }}-${{ github.job }}-
103+
${{ runner.os }}-
104+
105+
- name: Cache node modules
106+
uses: actions/cache@v2
107+
env:
108+
cache-name: warehouse-cache-node-modules
109+
with:
110+
path: |
111+
~/.npm
112+
**/node_modules
113+
key: ${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
114+
restore-keys: |
115+
${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-
116+
${{ runner.os }}-build-${{ github.job }}-
117+
${{ runner.os }}-build-
118+
${{ runner.os }}-
119+
120+
- name: Dependency setup
119121
run: |
122+
npm install eslint --save-dev
120123
sudo apt-get update && sudo apt-get install make
121-
make lint ACTIONS=true
124+
125+
- name: Lint
126+
run: make lint ACTIONS=true
122127

123128
docs:
124129
runs-on: ubuntu-latest
@@ -128,7 +133,7 @@ jobs:
128133

129134
- uses: actions/setup-python@v2
130135
with:
131-
python-version: 3.8
136+
python-version: ${{ env.PYTHON_VERSION }}
132137

133138
- name: Documentation
134139
run: |
@@ -143,26 +148,20 @@ jobs:
143148

144149
- uses: actions/setup-python@v2
145150
with:
146-
python-version: 3.8
151+
python-version: ${{ env.PYTHON_VERSION }}
147152

148153
- name: Cache pip dependencies
149154
uses: actions/cache@v2
150155
env:
151-
cache-name: cache-pip-deps-warehouse-p
156+
cache-name: warehouse-cache-pip
152157
with:
153158
path: ~/.cache/pip
154-
key: ${{ runner.os }}-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('requirements.txt') }}
159+
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('requirements.txt') }}
155160
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 }}-
161+
${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-
162+
${{ runner.os }}-${{ github.job }}-
159163
${{ runner.os }}-
160164
161-
- name: Set cache permissions
162-
run: |
163-
mkdir ~/.cache && mkdir ~/.cache/pip
164-
chown -R $(whoami) ~/.cache/pip
165-
166165
- name: Check dependencies
167166
run: |
168167
sudo apt -y install libcurl4-openssl-dev libssl-dev pkg-config
@@ -185,47 +184,51 @@ jobs:
185184

186185
- uses: actions/setup-python@v2
187186
with:
188-
python-version: 3.8
187+
python-version: ${{ env.PYTHON_VERSION }}
189188

190189
- name: Check translations
191190
run: make translations
192191

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-
205192
static-tests:
206193
runs-on: ubuntu-latest
207194
steps:
208195
- name: Check out repository
209196
uses: actions/checkout@v2
210197

198+
- name: Cache node version manager
199+
uses: actions/cache@v2
200+
env:
201+
cache-name: warehouse-cache-nvm
202+
with:
203+
path: ~/.nvm/versions/
204+
key: ${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
205+
restore-keys: |
206+
${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-
207+
${{ runner.os }}-build-${{ github.job }}-
208+
${{ runner.os }}-build-
209+
${{ runner.os }}-
210+
211211
- name: Cache node modules
212212
uses: actions/cache@v2
213213
env:
214-
cache-name: cache-node-modules-static-dh
214+
cache-name: warehouse-cache-npm-modules-static
215215
with:
216216
path: |
217217
~/.npm
218218
**/node_modules
219-
key: ${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
219+
key: ${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
220220
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 }}-
221+
${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-
222+
${{ runner.os }}-build-${{ github.job }}-
224223
${{ runner.os }}-build-
225224
${{ runner.os }}-
226225
227-
- name: Dependency Setup
228-
run: npm install -D babel
226+
- uses: actions/setup-node@v1
227+
with:
228+
node-version: ${{ env.NODE_VERSION }}
229+
230+
- name: Node dependency setup
231+
run: npm ci
229232

230233
- name: Static Tests
231234
run: bin/static_tests
@@ -239,35 +242,37 @@ jobs:
239242
- name: Cache node version manager
240243
uses: actions/cache@v2
241244
env:
242-
cache-name: cache-nvm-pipeline-dh
245+
cache-name: warehouse-cache-nvm
243246
with:
244247
path: ~/.nvm/versions/
245-
key: ${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
248+
key: ${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
246249
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 }}-
250+
${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-
251+
${{ runner.os }}-build-${{ github.job }}-
250252
${{ runner.os }}-build-
251253
${{ runner.os }}-
252254
253255
- name: Cache node modules
254256
uses: actions/cache@v2
255257
env:
256-
cache-name: cache-node-modules-static-dh
258+
cache-name: warehouse-cache-npm-modules
257259
with:
258260
path: |
259261
~/.npm
260262
**/node_modules
261-
key: ${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
263+
key: ${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
262264
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 }}-
265+
${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-
266+
${{ runner.os }}-build-${{ github.job }}-
266267
${{ runner.os }}-build-
267268
${{ runner.os }}-
268269
269-
- name: Dependency Setup
270-
run: npm install -D babel
270+
- uses: actions/setup-node@v1
271+
with:
272+
node-version: ${{ env.NODE_VERSION }}
273+
274+
- name: Node dependency setup
275+
run: npm ci
271276

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