Skip to content

Commit 8ccd126

Browse files
committed
simplifying dependency setup
1 parent 5fc9837 commit 8ccd126

File tree

4 files changed

+85
-64
lines changed

4 files changed

+85
-64
lines changed

.github/workflows/main.yml

Lines changed: 79 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on: [push, pull_request]
44

55
env:
66
CACHE_SEED: 1
7+
PYTHON_VERSION: 3.8.2
78
NODE_VERSION: 14.4.0
89

910
jobs:
@@ -26,14 +27,14 @@ jobs:
2627

2728
- uses: actions/setup-python@v2
2829
with:
29-
python-version: 3.8
30+
python-version: ${{ env.PYTHON_VERSION }}
3031

3132
- name: Cache pip dependencies
3233
uses: actions/cache@v2
3334
env:
34-
cache-name: cache-pip-tests-warehouse-p
35+
cache-name: cache-pip-warehouse-tests-native-1 # TODO: remove native
3536
with:
36-
path: ./.cache/pip
37+
path: ~/.cache/pip
3738
key: ${{ runner.os }}-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('requirements.txt') }}
3839
restore-keys: |
3940
${{ runner.os }}-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-
@@ -71,25 +72,22 @@ jobs:
7172
${{ runner.os }}-build-
7273
${{ runner.os }}-
7374
75+
- uses: actions/setup-node@v1
76+
with:
77+
node-version: ${{ env.NODE_VERSION }}
78+
7479
- name: Install dependencies
7580
run: sudo apt -y install libcurl4-openssl-dev libssl-dev pkg-config
7681

7782
- name: Install pip requirements
7883
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
84+
pip install -U pip setuptools wheel
85+
pip install -r requirements/main.txt
86+
pip install -r requirements/tests.txt
87+
pip install -r requirements/deploy.txt
8588
8689
- name: Setup node
8790
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
9391
npm i -g npm
9492
npm install -g gulp-cli
9593
npm ci
@@ -99,11 +97,6 @@ jobs:
9997
python -m coverage run -m pytest --strict --postgresql-host localhost
10098
python -m coverage html
10199
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
107100
108101
lint:
109102
runs-on: ubuntu-latest
@@ -113,12 +106,42 @@ jobs:
113106

114107
- uses: actions/setup-python@v2
115108
with:
116-
python-version: 3.8
109+
python-version: ${{ env.PYTHON_VERSION }}
117110

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

123146
docs:
124147
runs-on: ubuntu-latest
@@ -128,7 +151,7 @@ jobs:
128151

129152
- uses: actions/setup-python@v2
130153
with:
131-
python-version: 3.8
154+
python-version: ${{ env.PYTHON_VERSION }}
132155

133156
- name: Documentation
134157
run: |
@@ -143,12 +166,12 @@ jobs:
143166

144167
- uses: actions/setup-python@v2
145168
with:
146-
python-version: 3.8
169+
python-version: ${{ env.PYTHON_VERSION }}
147170

148171
- name: Cache pip dependencies
149172
uses: actions/cache@v2
150173
env:
151-
cache-name: cache-pip-deps-warehouse-p
174+
cache-name: cache-pip-deps-warehouse-native-2 # TODO: remove native 2
152175
with:
153176
path: ~/.cache/pip
154177
key: ${{ runner.os }}-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('requirements.txt') }}
@@ -158,11 +181,6 @@ jobs:
158181
${{ runner.os }}-${{ env.CACHE_SEED }}-
159182
${{ runner.os }}-
160183
161-
- name: Set cache permissions
162-
run: |
163-
mkdir ~/.cache && mkdir ~/.cache/pip
164-
chown -R $(whoami) ~/.cache/pip
165-
166184
- name: Check dependencies
167185
run: |
168186
sudo apt -y install libcurl4-openssl-dev libssl-dev pkg-config
@@ -185,33 +203,35 @@ jobs:
185203

186204
- uses: actions/setup-python@v2
187205
with:
188-
python-version: 3.8
206+
python-version: ${{ env.PYTHON_VERSION }}
189207

190208
- name: Check translations
191209
run: make translations
192210

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-
205211
static-tests:
206212
runs-on: ubuntu-latest
207213
steps:
208214
- name: Check out repository
209215
uses: actions/checkout@v2
210216

217+
- name: Cache node version manager
218+
uses: actions/cache@v2
219+
env:
220+
cache-name: cache-nvm-static-dh
221+
with:
222+
path: ~/.nvm/versions/
223+
key: ${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
224+
restore-keys: |
225+
${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-
226+
${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-
227+
${{ runner.os }}-build-${{ env.CACHE_SEED }}-
228+
${{ runner.os }}-build-
229+
${{ runner.os }}-
230+
211231
- name: Cache node modules
212232
uses: actions/cache@v2
213233
env:
214-
cache-name: cache-node-modules-static-dh
234+
cache-name: cache-npm-modules-static-dh
215235
with:
216236
path: |
217237
~/.npm
@@ -224,8 +244,12 @@ jobs:
224244
${{ runner.os }}-build-
225245
${{ runner.os }}-
226246
227-
- name: Dependency Setup
228-
run: npm install -D babel
247+
- uses: actions/setup-node@v1
248+
with:
249+
node-version: ${{ env.NODE_VERSION }}
250+
251+
- name: Node dependency setup
252+
run: npm ci
229253

230254
- name: Static Tests
231255
run: bin/static_tests
@@ -239,7 +263,7 @@ jobs:
239263
- name: Cache node version manager
240264
uses: actions/cache@v2
241265
env:
242-
cache-name: cache-nvm-pipeline-dh
266+
cache-name: cache-nvm-static-dh
243267
with:
244268
path: ~/.nvm/versions/
245269
key: ${{ runner.os }}-build-${{ env.CACHE_SEED }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
@@ -253,7 +277,7 @@ jobs:
253277
- name: Cache node modules
254278
uses: actions/cache@v2
255279
env:
256-
cache-name: cache-node-modules-static-dh
280+
cache-name: cache-npm-modules-static-dh
257281
with:
258282
path: |
259283
~/.npm
@@ -266,8 +290,12 @@ jobs:
266290
${{ runner.os }}-build-
267291
${{ runner.os }}-
268292
269-
- name: Dependency Setup
270-
run: npm install -D babel
293+
- uses: actions/setup-node@v1
294+
with:
295+
node-version: ${{ env.NODE_VERSION }}
296+
297+
- name: Node dependency setup
298+
run: npm ci
271299

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