Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate CI to github actions #677

Merged
merged 82 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
5afebcd
initial gh actions workflow
thatbudakguy May 29, 2020
dce0c5b
remove errant backtick
thatbudakguy May 29, 2020
e5bcb9c
add solr setup steps
thatbudakguy May 29, 2020
31f3bb1
create test db; add dep caching
thatbudakguy May 29, 2020
07955af
start mysql service
thatbudakguy May 29, 2020
44d904b
use default mysql password
thatbudakguy May 29, 2020
055b29f
add root password to testsettings
thatbudakguy May 29, 2020
3b215b8
fix caching step order
thatbudakguy May 29, 2020
112289b
add webpack build step
thatbudakguy May 29, 2020
65e48c8
separate out static file builds
thatbudakguy May 29, 2020
4a1f2bc
add install step
thatbudakguy May 29, 2020
1539ae6
upload webpack stats file
thatbudakguy May 29, 2020
32eaaba
try using codecov flags
thatbudakguy May 29, 2020
095ae5b
edit python coverage path
thatbudakguy May 29, 2020
0b6c8dd
remove travis
thatbudakguy May 29, 2020
e08e5fc
update README badge
thatbudakguy May 29, 2020
0183c8d
update sitemap to use main sitemap
thatbudakguy May 29, 2020
b9851de
add a11y testing job
thatbudakguy May 29, 2020
129ceeb
install pa11y-ci
thatbudakguy May 29, 2020
f689cd8
expand list of URLs crawled by pa11y
thatbudakguy May 29, 2020
a6146c9
try using service containers
thatbudakguy May 29, 2020
b3468aa
array syntax for service container volumes
thatbudakguy May 29, 2020
3481d47
specify solr conf dir using workspace envvar
thatbudakguy May 29, 2020
62d8694
use different collection name
thatbudakguy May 29, 2020
d055c34
try a different path
thatbudakguy May 29, 2020
6df52d3
try manually creating core
thatbudakguy May 29, 2020
2e58327
don't run main build in container
thatbudakguy May 29, 2020
93bf605
try manually copying core conf
thatbudakguy May 29, 2020
df9ec68
try using shared volume
thatbudakguy May 29, 2020
b8e75ff
try using docker cp
thatbudakguy May 29, 2020
7aa992a
re-bind ports
thatbudakguy May 29, 2020
f1671ea
change host param for db
thatbudakguy May 29, 2020
f87c662
change permissions of solr conf directory
thatbudakguy May 29, 2020
4b8bf8c
sudo
thatbudakguy May 29, 2020
c807880
use privileged flag
thatbudakguy May 29, 2020
aef5c6a
try...everything
thatbudakguy May 29, 2020
1a046b4
try the ol' 777
thatbudakguy May 29, 2020
48db027
try to su root
thatbudakguy May 29, 2020
5829df6
try using solr-precreate command
thatbudakguy Jun 1, 2020
141f656
use precreate-core command
thatbudakguy Jun 1, 2020
32b5053
restart solr container prior to creating core
thatbudakguy Jun 1, 2020
f51784a
use compose file to orchestrate containers
thatbudakguy Jun 1, 2020
ee82efd
use config_solr script but keep db in docker
thatbudakguy Jun 1, 2020
9f35dfa
add SOLR_VERSION env
thatbudakguy Jun 1, 2020
39c0bec
try node matrix
thatbudakguy Jun 2, 2020
c048751
test python matrix
thatbudakguy Jun 2, 2020
0ac5e59
update py version caches; change pa11y command
thatbudakguy Jun 2, 2020
e42a55e
set up lighthouse ci
thatbudakguy Jun 2, 2020
a76d3b4
pass in lhci github token
thatbudakguy Jun 2, 2020
985a56b
add lighthouse URLs and set readyPattern
thatbudakguy Jun 2, 2020
3531f3a
fix urls, try letting lighthouse serve static/
thatbudakguy Jun 2, 2020
0bf7ad6
don't serve static with lighthouse
thatbudakguy Jun 2, 2020
02c858f
update webpack stats file path
thatbudakguy Jun 2, 2020
56f5b3e
rename and separate stats/bundle
thatbudakguy Jun 2, 2020
e2c2d6b
make a11y dependent on other tests; pull out NODE_VERSION
thatbudakguy Jul 7, 2020
84b5f2b
re-add webpack bundle to py unit tests
thatbudakguy Jul 7, 2020
e71dc1f
add more URLs to test with lighthouse
thatbudakguy Jul 7, 2020
aef9dcc
remove lighthouse from CI
thatbudakguy Jul 20, 2020
3a96864
update from develop
thatbudakguy Jul 20, 2020
fb59bcd
remove lighthouse token from ci workflow
thatbudakguy Jul 20, 2020
97f085c
make python unit tests depend on webpack build
thatbudakguy Jul 20, 2020
34751a3
Try using Solr service
rlskoeser Jan 15, 2021
3070e18
Rename ci/unit test workflow
rlskoeser Jan 15, 2021
3ca5e5d
Add python version file; remove matrix build strategy
rlskoeser Jan 15, 2021
d51546f
Add wheel to dev requirements
rlskoeser Jan 15, 2021
8f57e84
Use python version 3.5.4 since 3.5.1 is unavailable
rlskoeser Jan 15, 2021
eeb8c16
Create project configset using Solr ConfigSets API
rlskoeser Jan 19, 2021
06d324f
Try using docker cp to get configset files to Solr service container
rlskoeser Jan 19, 2021
439a795
Try using context variable to get id for solr service container
rlskoeser Jan 19, 2021
555789c
Require wagtail < 2.10 since production is still python 3.5 for now
rlskoeser Jan 19, 2021
0ef20ca
Try setting ownership on configset files in service container
rlskoeser Jan 19, 2021
a8ede18
Revise slack notification message
rlskoeser Jan 20, 2021
402c1e7
Merge branch 'develop' into thatbudakguy/issue634
rlskoeser Jan 20, 2021
826fd50
Revise slack message format
rlskoeser Jan 20, 2021
dfea8d1
Tweak slack message
rlskoeser Jan 20, 2021
cfc4ec0
Abandon attempts to get short ref for slack message
rlskoeser Jan 20, 2021
d09e53b
Try waiting longer after indexing test data in solr
rlskoeser Jan 20, 2021
9589c3d
Remove formatting from slack message title
rlskoeser Jan 20, 2021
fc86a12
Merge branch 'develop' into thatbudakguy/issue634
rlskoeser Jan 20, 2021
96c2e61
Remove pa11y-ci references and lighthouse config
rlskoeser Jan 20, 2021
d9bbf8e
Merge branch 'develop' into thatbudakguy/issue634
rlskoeser Jan 20, 2021
cffefbb
Try using parasolr<0.6 to resolve issue with stats for search forms
rlskoeser Jan 20, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 163 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
name: unit_tests

on: [push, pull_request]

env:
NODE_VERSION: 10
SOLR_VERSION: 6.6.5

jobs:

build-static:
name: Build static files
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2-beta
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-${{ hashFiles('package-lock.json') }}
npm-
- name: Install dependencies
run: npm ci
- name: Run webpack build
run: npm run build:prod
- name: Upload built files
uses: actions/upload-artifact@v2
with:
name: bundles
path: bundles/
- name: Upload stats file
uses: actions/upload-artifact@v2
with:
name: webpack-stats.json
path: webpack-stats.json

ts-unit:
name: TypeScript unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2-beta
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-${{ hashFiles('package-lock.json') }}
npm-
- name: Install dependencies
run: npm ci
- name: Run Jest
run: npx jest --collectCoverage
- name: Upload test coverage to Codecov
uses: codecov/codecov-action@v1
with:
flags: typescript

py-unit:
name: Python unit tests
runs-on: ubuntu-latest
needs: build-static
services:
db:
image: mariadb
env:
MYSQL_DATABASE: sandco
MYSQL_ROOT_PASSWORD: sandco
ports:
- 3306:3306
solr:
image: solr:6.6
ports:
- 8983:8983
steps:
- name: Checkout repository
uses: actions/checkout@v2

# use docker cp to copy the configset, then bash to set ownership to solr
- name: Copy Solr configset to solr service
run: |
docker cp solr_conf ${{ job.services.solr.id }}:/opt/solr/server/solr/configsets/sandco
docker exec --user root ${{ job.services.solr.id }} /bin/bash -c "chown -R solr:solr /opt/solr/server/solr/configsets/sandco"
Comment on lines +91 to +95
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome that this worked; maybe we could extract it to a shell script at some point


# Python version to use is stored in the .python-version file, which is the
# convention for pyenv: https://github.com/pyenv/pyenv
- name: Get Python version
run: echo "PYTHON_VERSION=$(cat .python-version)" >> $GITHUB_ENV
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: pip-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
pip-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}
pip-${{ matrix.python }}
pip-

- name: Install dependencies
run: |
pip install -r requirements.txt
pip install -r dev-requirements.txt

- name: Download webpack stats
uses: actions/download-artifact@v2
with:
name: webpack-stats.json

- name: Setup local_settings.py
run: |
cp ci/testsettings.py mep/local_settings.py
python -c "import uuid; print('SECRET_KEY = \'%s\'' % uuid.uuid4())" >> mep/local_settings.py


- name: Run pytest
run: py.test --cov=./ --cov-report=xml

- name: Upload test coverage to Codecov
uses: codecov/codecov-action@v1
with:
flags: python

# Set the color of the slack message used in the next step based on the
# status of the build: "warning" for failure and "good" for success
- name: Set Slack message color based on build status
if: ${{ always() }}
env:
JOB_STATUS: ${{ job.status }}
run: echo "SLACK_COLOR=$(if [ "$JOB_STATUS" == "success" ]; then echo "good"; elif [ "$JOB_STATUS" == "failure" ]; then echo "danger"; else echo "warning"; fi)" >> $GITHUB_ENV

# Send a message to slack to report the build status. The webhook is stored
# at the organization level and available to all repositories. Only run on
# scheduled builds & pushes, since PRs automatically report to Slack.
- name: Report status to Slack
uses: rtCamp/action-slack-notify@master
if: ${{ always() && (github.event_name == 'schedule' || github.event_name == 'push') }}
continue-on-error: true
env:
SLACK_COLOR: ${{ env.SLACK_COLOR }}
SLACK_WEBHOOK: ${{ secrets.ACTIONS_SLACK_WEBHOOK }}
SLACK_TITLE: "Run #${{ github.run_number }} for workflow `${{ github.workflow }}`: ${{ job.status }}"
SLACK_MESSAGE: "<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|Run #${{ github.run_number }}> | <https://github.com/${{ github.repository }}/|${{ github.repository }}@${{ github.ref }}>"
SLACK_FOOTER: "<https://github.com/${{ github.repository }}/commit/${{ github.sha }}|View commit>"
MSG_MINIMAL: true # use compact slack message format


1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.5.4
48 changes: 0 additions & 48 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ bookstore and lending library in Paris.

Python 3.5 / Django 2.2 / Node 10.5.0 / MariaDB (MySQL) 5.5+ w/ timezone info / Solr 6.6

.. image:: https://github.com/Princeton-CDH/mep-django/workflows/unit_tests/badge.svg
:target: https://github.com/Princeton-CDH/mep-django/actions?query=workflow%3Aunit_tests
:alt: Unit Test status

.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.3834179.svg
:target: https://doi.org/10.5281/zenodo.3834179

Expand Down
11 changes: 4 additions & 7 deletions ci/testsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,15 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
# Django needs to make databases in the test mysql server
'NAME': 'travismep',
'NAME': 'sandco',
'USER': 'root',
'PASSWORD': '',
'PASSWORD': 'sandco',
'HOST': '127.0.0.1',
'OPTIONS': {
# In each case, we want strict mode on to catch truncation issues
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
# Load the socket info from .my.cnf in the travis user
'read_default_file': '~travis/.my.cnf'
},
'PORT': '',
'PORT': '3306',
'TEST': {
# We also want the test databse to for utf8 and the general
# collation to keep case sensitive unicode searches working
Expand All @@ -36,7 +33,7 @@
SOLR_CONNECTIONS = {
'default': {
'URL': 'http://localhost:8983/solr/',
'COLLECTION': 's-and-co',
'COLLECTION': 'sandco',
'CONFIGSET': 'sandco',
'TEST': {
# aggressive commitWithin for test only
Expand Down
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ pytest-ordering
#pytest-sugar
django-debug-toolbar
sphinx
wheel
2 changes: 1 addition & 1 deletion mep/people/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ def test_list(self):
account.card = card
account.save()
Person.index_items(Person.objects.all())
time.sleep(1)
time.sleep(2)

response = self.client.get(self.members_url)

Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"start": "npm run dev",
"test": "npm run test:unit && npm run test:a11y",
"test:unit": "jest --collectCoverage",
"test:a11y": "pa11y-ci --sitemap http://localhost:8000/sitemap-pages.xml",
"build:qa": "NODE_ENV=production webpack --env.maps",
"build:prod": "NODE_ENV=production webpack --env"
},
Expand Down Expand Up @@ -48,7 +47,6 @@
"node-sass": "^4.14.1",
"node-sass-glob-importer": "^5.3.0",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"pa11y-ci": "^2.4.0",
"postcss-loader": "^3.0.0",
"sass-loader": "^7.1.0",
"source-map-loader": "^0.2.4",
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ django-apptemplates
py-flags
django-tabular-export
django-webpack-loader
parasolr>=0.5.3
# parasolr 0.6 has a regression in getting stats
parasolr>=0.5.3,<0.6
django-widget-tweaks
pymarc
progressbar2
Expand Down