Skip to content

Commit

Permalink
Work on CI setup (#70).
Browse files Browse the repository at this point in the history
* Switch from Travis to GitHub actions.
* Introduce caching of docker build.
* Split off pre-commit and docs build that don't need the docker setup.
* Pin RASPA version that is tested against
* Relax AiiDA version constraint (note: the aiida-core docker containers now anyhow contain a pre-2.0 version)
* Remove prospector dependency (was anyhow just using pylint).
* Remove .pylintrc and pytest.ini in favour of compact pyproject.toml.

Overall, these improvements reduce the test duration from >17minutes in the last successful build
to <5 minutes when the cache can be reused (see e.g. here).
Information on pre-commit and docs is available already after 1min30.
  • Loading branch information
ltalirz authored Apr 30, 2021
1 parent 5eece84 commit 5aaaaca
Show file tree
Hide file tree
Showing 12 changed files with 179 additions and 530 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Continuous Integration

on: [push, pull_request]

jobs:

test-plugin:

runs-on: ubuntu-latest
timeout-minutes: 30

steps:

- uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

# see https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#github-cache
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build #and push
uses: docker/build-push-action@v2
with:
context: .
push: false
load: true
tags: aiida_raspa_test
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Run tests
run: |
export DOCKERID=`docker run -d aiida_raspa_test`
docker exec --tty $DOCKERID wait-for-services
docker logs $DOCKERID
docker exec --tty --user aiida $DOCKERID /bin/bash -l -c 'cd /opt/aiida-raspa/ && py.test --cov aiida_raspa --cov-append .'
# see https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables
docker exec --tty --user aiida --env-file <(env | grep GITHUB_) -e GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} $DOCKERID /bin/bash -l -c 'cd /opt/aiida-raspa/ && coveralls --service=github'
pre-commit:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
python-version: [3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[pre-commit,test,docs]
reentry scan
- name: Run pre-commit
run: |
pre-commit install
pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )
docs:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
python-version: [3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[docs,test]
reentry scan
- name: Build docs
run: |
cd docs && make
23 changes: 15 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
# # Install pre-commit hooks via
# pre-commit install

- repo: local
repos:
- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.30.0
hooks:
# yapf = yet another python formatter
- id: yapf
name: yapf
entry: yapf
language: system
types: [python]
args: ["-i"]
exclude: >
(?x)^(
docs/.*|
)$
args: ['-i']

- repo: local
hooks:
# yapf = yet another python formatter

# prospector: collection of linters
- id: prospector
- id: pylint
language: system
types: [file, python]
name: prospector
description: "This hook runs Prospector: https://github.com/landscapeio/prospector"
entry: prospector
name: pylint
entry: pylint
19 changes: 0 additions & 19 deletions .prospector.yaml

This file was deleted.

Loading

0 comments on commit 5aaaaca

Please sign in to comment.