10000 github action? · python/pythondotorg@06916fe · GitHub
[go: up one dir, main page]

Skip to content

Commit 06916fe

Browse files
committed
github action?
1 parent bff9f00 commit 06916fe

File tree

3 files changed

+132
-0
lines changed

3 files changed

+132
-0
lines changed

.github/workflows/ci.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: CI
2+
on: [push, pull_request]
3+
4+
jobs:
5+
test:
6+
strategy:
7+
matrix:
8+
include:
9+
- name: Tests
10+
command: bin/tests --postgresql-host localhost
11+
needs-python: ${{ true }}
12+
needs-node: ${{ false }}
13+
- name: Lint
14+
command: bin/scss-check
15+
needs-python: ${{ false }}
16+
needs-node: ${{ true }}
17+
runs-on: ubuntu-latest
18+
services:
19+
postgres:
20+
image: postgres:10.1
21+
ports:
22+
- 5432:5432
23+
options: >-
24+
--health-cmd pg_isready
25+
--health-interval 10s
26+
--health-timeout 5s
27+
--health-retries 5
28+
name: ${{ matrix.name }}
29+
steps:
30+
- name: Check out repository
31+
uses: actions/checkout@v2
32+
- name: Install platform dependencies
33+
run: |
34+
sudo apt -y update
35+
sudo apt -y install libcurl4-openssl-dev libssl-dev pkg-config
36+
- uses: actions/setup-python@v2
37+
if: ${{ matrix.needs-python }}
38+
with:
39+
python-version: 3.6.6
40+
- name: Cache Python dependencies
41+
if: ${{ matrix.needs-python }}
42+
uses: actions/cache@v2
43+
env:
44+
cache-name: pythondotorg-cache-pip
45+
with:
46+
path: ~/.cache/pip
47+
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('dev-requirements.txt') }}
48+
restore-keys: |
49+
${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-
50+
${{ runner.os }}-${{ github.job }}-
51+
${{ runner.os }}-
52+
- name: Install Python dependencies
53+
if: ${{ matrix.needs-python }}
54+
run: |
55+
pip install -U pip setuptools wheel
56+
pip install -r dev-requirements.txt
57+
- uses: actions/setup-node@v2
58+
if: ${{ matrix.needs-node }}
59+
with:
60+
node-version: 14
61+
- name: Cache Node dependencies
62+
if: ${{ matrix.needs-node }}
63+
uses: actions/cache@v2
64+
env:
65+
cache-name: warehouse-cache-npm
66+
with:
67+
path: ~/.npm
68+
key: ${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
69+
restore-keys: |
70+
${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-
71+
${{ runner.os }}-build-${{ github.job }}-
72+
${{ runner.os }}-build-
73+
${{ runner.os }}-
74+
- name: Create DB
75+
run: psql -c 'create database "python.org";' -U postgres
76+
- name: Install Node dependencies
77+
if: ${{ matrix.needs-node }}
78+
run: npm ci
79+
- name: Run ${{ matrix.name }}
80+
run: ${{ matrix.command }}
81+
env:
82+
DATABASE_URL: postgres://postgres:@127.0.0.1:5432/python.org

bin/scss-check

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
EXIT_CODE=0
4+
5+
PATH=$(npm bin):$PATH sass -I static/vendor/compass -I static/vendor/susy static/sass
6+
if git diff --quiet HEAD -- static; then
7+
echo "SCSS is compiled!"
8+
else
9+
echo "Committed CSS does not match result of compiling SCSS!"
10+
EXIT_CODE=1;
11+
fi
12+
13+
exit $EXIT_CODE

bin/tests

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Click requires us to ensure we have a well configured environment to run
5+
# our click commands. So we'll set our environment to ensure our locale is
6+
# correct.
7+
export LC_ALL="${ENCODING:-en_US.UTF-8}"
8+
export LANG="${ENCODING:-en_US.UTF-8}"
9+
10+
COMMAND_ARGS=$@
11+
12+
# Test the postgres connection
13+
while [ $# -gt 0 ]; do
14+
case $1 in
15+
"--postgresql-host") POSTGRES_HOST="$2"
16+
esac
17+
shift
18+
done
19+
20+
# Test the postgres connection
21+
ATTEMPTS=0
22+
until [ $ATTEMPTS -eq 5 ] || pg_isready -t 10 -h $POSTGRES_HOST; do
23+
>&2 echo "Postgres is unavailable, sleeping"
24+
sleep $(( ATTEMPTS++ ))
25+
done
26+
27+
if [ $ATTEMPTS -eq 5 ]; then
28+
>&2 echo "Postgres is unavailable, exiting"
29+
exit 1
30+
fi
31+
32+
# Print all the followng commands
33+
set -x
34+
35+
# Actually run our tests.
36+
python -Wd -m coverage run manage.py test -v2
37+
coverage report -m --fail-under=75

0 commit comments

Comments
 (0)
0