Skip to content

Commit 0dc06c8

Browse files
committed
GitHub Actions
1 parent 93b89d9 commit 0dc06c8

File tree

2 files changed

+84
-3
lines changed

2 files changed

+84
-3
lines changed

.github/workflows/ci.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: CI
2+
on: [push, pull_request]
3+
jobs:
4+
test:
5+
strategy:
6+
matrix:
7+
include:
8+
- name: Tests
9+
command: bin/tests --postgresql-host localhost
10+
- name: Lint
11+
command: make lint BINDIR="$(dirname $(which python))"
12+
- name: Documentation
13+
command: make docs BINDIR="$(dirname $(which python))"
14+
- name: Dependencies
15+
command: make github-actions-deps BINDIR="$(dirname $(which python))"
16+
- name: Licenses
17+
command: make licenses BINDIR="$(dirname $(which python))"
18+
- name: Translations
19+
command: make translations BINDIR="$(dirname $(which python))"
20+
- name: Static Tests
21+
command: bin/static_tests
22+
- name: Static Pipeline
23+
command: bin/static_pipeline
24+
runs-on: ubuntu-latest
25+
services:
26+
postgres:
27+
image: postgres:10.1
28+
ports:
29+
- 5432:5432
30+
name: ${{ matrix.name }}
31+
steps:
32+
- name: Check out repository
33+
uses: actions/checkout@v2
34+
- name: Install platform dependencies
35+
run: sudo apt -y install libcurl4-openssl-dev libssl-dev pkg-config
36+
- uses: actions/setup-python@v2
37+
with:
38+
python-version: 3.8.2
39+
- name: Cache Python dependencies
40+
uses: actions/cache@v2
41+
env:
42+
cache-name: warehouse-cache-pip
43+
with:
44+
path: ~/.cache/pip
45+
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('requirements.txt', 'requirements/*.txt') }}
46+
restore-keys: |
47+
${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-
48+
${{ runner.os }}-${{ github.job }}-
49+
${{ runner.os }}-
50+
- name: Install Python dependencies
51+
run: |
52+
pip install -U pip setuptools wheel
53+
pip install -r requirements.txt
54+
pip install -r requirements/dev.txt
55+
- uses: actions/setup-node@v2
56+
with:
57+
node-version: 14.4.0
58+
- name: Cache Node dependencies
59+
uses: actions/cache@v2
60+
env:
61+
cache-name: warehouse-cache-npm
62+
with:
63+
path: ~/.npm
64+
key: ${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
65+
restore-keys: |
66+
${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-
67+
${{ runner.os }}-build-${{ github.job }}-
68+
${{ runner.os }}-build-
69+
${{ runner.os }}-
70+
- name: Install Node dependencies
71+
run: npm ci
72+
- name: Run ${{ matrix.name }}
73+
run: ${{ matrix.command }}

Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ BINDIR = $(PWD)/.state/env/bin
22
TRAVIS := $(shell echo "$${TRAVIS:-false}")
33
PR := $(shell echo "$${TRAVIS_PULL_REQUEST:-false}")
44
BRANCH := $(shell echo "$${TRAVIS_BRANCH:-master}")
5+
GITHUB_ACTIONS := $(shell echo "$${GITHUB_ACTIONS:-false}")
6+
GITHUB_HEAD_REF := $(shell echo "$${GITHUB_HEAD_REF:-false}")
57
DB := example
68
IPYTHON := no
79
LOCALES := $(shell .state/env/bin/python -c "from warehouse.i18n import KNOWN_LOCALES; print(' '.join(set(KNOWN_LOCALES)-{'en'}))")
@@ -110,12 +112,12 @@ lint: .state/env/pyvenv.cfg
110112
$(BINDIR)/doc8 --allow-long-titles README.rst CONTRIBUTING.rst docs/ --ignore-path docs/_build/
111113
$(BINDIR)/curlylint ./warehouse/templates
112114

113-
ifneq ($(TRAVIS), false)
114-
# We're on Travis, so we can lint static files locally
115+
ifneq ($(filter false,$(TRAVIS) $(GITHUB_ACTIONS)),)
116+
# We're either on Travis or GitHub Actions, so we can lint static files locally
115117
./node_modules/.bin/eslint 'warehouse/static/js/**' '**.js' 'tests/frontend/**' --ignore-pattern 'warehouse/static/js/vendor/**'
116118
./node_modules/.bin/sass-lint --verbose
117119
else
118-
# We're not on Travis, so we should lint static files inside the static container
120+
# We're not on Travis or GitHub Actions, so we should lint static files inside the static container
119121
docker-compose run --rm static ./node_modules/.bin/eslint 'warehouse/static/js/**' '**.js' 'tests/frontend/**' --ignore-pattern 'warehouse/static/js/vendor/**'
120122
docker-compose run --rm static ./node_modules/.bin/sass-lint --verbose
121123
endif
@@ -139,6 +141,12 @@ deps: .state/env/pyvenv.cfg
139141
rm -r $(TMPDIR)
140142
$(BINDIR)/pip check
141143

144+
github-actions-deps:
145+
ifneq ($(GITHUB_HEAD_REF), false)
146+
git fetch origin $(GITHUB_HEAD_REF):refs/remotes/origin/$(GITHUB_HEAD_REF)
147+
git diff --name-only $(GITHUB_HEAD_REF) | grep '^requirements/' || exit 0 && $(MAKE) deps
148+
endif
149+
142150
travis-deps:
143151
ifneq ($(PR), false)
144152
git fetch origin $(BRANCH):refs/remotes/origin/$(BRANCH)

0 commit comments

Comments
 (0)