Skip to content

Commit

Permalink
Merge pull request #132 from sanger/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
pjvv authored May 6, 2021
2 parents 6deef51 + 10256dd commit 85e0de1
Show file tree
Hide file tree
Showing 47 changed files with 1,168 additions and 700 deletions.
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
.coverage
.dockerignore
.DS_Store
.editorconfig
.env
.env.example
.git
.github
.gitignore
.mypy_cache
.pytest_cache
.release-version
coverage.xml
docker-compose.yml
Dockerfile
forlint.sh
htmlcov
LICENSE
mypy.ini
pyproject.toml
README.md
setup.cfg
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{*.yml,Dockerfile}]
indent_size = 2
15 changes: 2 additions & 13 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,2 @@
DB_DBNAME=baracoda_dev
DB_HOST=localhost
DB_PASSWORD=postgres
DB_PORT=5432
DB_USER=postgres
FLASK_APP=baracoda
FLASK_ENV=development
SEQUENCE_NAME=heron
SEQUENCE_START=200000
SLACK_API_TOKEN=xoxb-123
SLACK_CHANNEL_ID=Cxxx
SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://postgres:postgres@localhost:5432/baracoda_dev"
SETTINGS_PATH=config/defaults.py
# path to the settings file which flask will use
SETTINGS_PATH=config/development.py
12 changes: 12 additions & 0 deletions .flaskenv
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# use publicly acessible env variables in this file
# https://flask.palletsprojects.com/en/1.1.x/cli/#environment-variables-from-dotenv

# https://flask.palletsprojects.com/en/1.1.x/cli/#application-discovery
FLASK_APP=baracoda

# https://flask.palletsprojects.com/en/1.1.x/cli/#setting-command-options
FLASK_RUN_HOST=0.0.0.0
FLASK_RUN_PORT=8000

# https://flask.palletsprojects.com/en/1.1.x/config/#environment-and-debug-features
FLASK_ENV=development
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
time: "07:00"
timezone: Europe/London
open-pull-requests-limit: 10
75 changes: 41 additions & 34 deletions .github/workflows/automated_release_and_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ on:
branches:
- develop
- master
paths-ignore:
- "README.md"


env:
IMAGE_NAME: ${{ github.repository }}/${{ github.event.repository.name }}

jobs:
build_and_test_job:
build_test_release_push:
runs-on: ubuntu-18.04
services:
postgres:
Expand All @@ -30,46 +28,55 @@ jobs:
--health-retries 5
steps:
- uses: actions/checkout@v2
- name: Set release tag
# Generate a release tag name in the format:
# devel/YYYY-MM-DD/HHMMSS
# Writes this out to the environment file for use downstream
run: |
echo "RELEASE_TAG=$([ ${GITHUB_REF##*/} = "develop" ] && printf '%s\n' $(cat .release-version)_develop || printf '%s\n' $(cat .release-version))" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ env.RELEASE_TAG }}
release_name: ${{ env.RELEASE_TAG }}
draft: false
prerelease: ${{ !(github.ref == 'refs/heads/master') }}
- name: Build the Docker image

- name: Build and tag the image for testing
run: >-
docker build .
--file Dockerfile
--tag docker.pkg.github.com/${IMAGE_NAME}:${{ env.RELEASE_TAG }}
- name: Run mypy against the image
run: >-
docker run
--network host
docker.pkg.github.com/${IMAGE_NAME}:${{ env.RELEASE_TAG }}
mypy .
--tag docker.pkg.github.com/${IMAGE_NAME}:${GITHUB_REF##*/}
- name: Run tests against the image
run: >-
docker run
--network host
docker.pkg.github.com/${IMAGE_NAME}:${{ env.RELEASE_TAG }}
python -m pytest -vsx
- name: Login to regitry
--env SETTINGS_PATH=config/test.py
--entrypoint=""
docker.pkg.github.com/${IMAGE_NAME}:${GITHUB_REF##*/}
python -m pytest --no-cov -vx
- name: Set release tag
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
run: echo "RELEASE_VERSION=$([ ${GITHUB_REF##*/} = "develop" ] && printf '%s\n' $(cat .release-version)-develop || printf '%s\n' $(cat .release-version))" >> $GITHUB_ENV

- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.RELEASE_VERSION }}
release_name: ${{ env.RELEASE_VERSION }}
draft: false
prerelease: ${{ !(github.ref == 'refs/heads/master') }}

- name: Login to registry
run: >-
docker login
-u ${{ github.actor }}
-p ${{ secrets.GITHUB_TOKEN }}
docker.pkg.github.com
- name: Publish image with image tag being either develop-timestamp or release-version
- name: Tag image with release version
run: >-
docker push
docker.pkg.github.com/${IMAGE_NAME}:${{ env.RELEASE_TAG }}
docker tag
docker.pkg.github.com/${IMAGE_NAME}:${GITHUB_REF##*/}
docker.pkg.github.com/${IMAGE_NAME}:${{ env.RELEASE_VERSION }}
- name: Push release tag image to registry
run: >-
docker push docker.pkg.github.com/${IMAGE_NAME}:${{ env.RELEASE_VERSION }}
- name: Remove the oldest package
uses: actions/delete-package-versions@v1
with:
package-name: "${{ github.event.repository.name }}"
42 changes: 27 additions & 15 deletions .github/workflows/check_release_name_bump.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Check release bump
# Checks that the .release-version file has been updated
name: Check release version

on:
pull_request:
Expand All @@ -8,20 +9,31 @@ on:

jobs:
check:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Set excluded release types
run: >-
if [ "${{ github.base_ref }}" = "master" ]; then
echo "exclude_types=draft|prerelease" >> $GITHUB_ENV
elif [ "${{ github.base_ref }}" = "develop" ]; then
echo "exclude_types=draft" >> $GITHUB_ENV
else
exit 1;
fi
- name: Get the latest release
id: last_release
uses: InsonusK/[email protected]
with:
myToken: ${{ github.token }}
exclude_types: ${{ env.exclude_types }}
view_top: 1

- name: get latest-release
id: last_release
uses: InsonusK/[email protected]
with:
myToken: ${{ github.token }}
view_top: 1

- name: Compare release names
run: |
if [ "${{ steps.last_release.outputs.tag_name }}" = "$(printf '%s\n' $(cat .release-version)_develop)" ] ||
[ "${{ steps.last_release.outputs.tag_name }}" = "$(printf '%s\n' $(cat .release-version))" ]; then exit 1; fi
- name: Compare releases
run: >-
if [ "${{ steps.last_release.outputs.tag_name }}" = "$(printf 'v%s-develop\n' $(cat .release-version))" ] ||
[ "${{ steps.last_release.outputs.tag_name }}" = "$(printf 'v%s\n' $(cat .release-version))" ]; then
exit 1;
fi
124 changes: 124 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: CI

on:
push:
branches:
- develop
- master
pull_request:
branches:
- develop
- master

jobs:
black:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/Pipfile') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install pipenv
run: |
pip install pipenv
- name: Install dependencies
run: |
pipenv sync --dev --system
- name: Check format with black
run: |
# stop the build if there are black formatting errors
python -m black --check .
flake8:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/Pipfile') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install pipenv
run: |
pip install pipenv
- name: Install dependencies
run: |
pipenv sync --dev --system
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8
mypy:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/Pipfile') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install pipenv
run: |
pip install pipenv
- name: Install dependencies
run: |
pipenv sync --dev --system
- name: Run mypy
run: |
python -m mypy .
test:
runs-on: ubuntu-18.04
services:
postgres:
image: postgres:9.6
ports:
- 5432:5432
env:
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
POSTGRES_DB: "baracoda_test"
options: >-
--health-cmd pg_isready
--health-interval 20s
--health-timeout 10s
--health-retries 5
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/Pipfile') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install pipenv
run: |
python -m pip install --upgrade pip
pip install pipenv
- name: Install dependencies
run: |
pipenv sync --dev --system
- name: Test with pytest
run: |
SETTINGS_PATH=config/test.py python -m pytest -vsx
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
Loading

0 comments on commit 85e0de1

Please sign in to comment.