Skip to content

Commit 8421287

Browse files
authored
Merge pull request #87 from VNG-Realisatie/stable_into_master
Stable into master
2 parents 1aef50e + 0237afe commit 8421287

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1794
-3675
lines changed

.github/workflows/ci.yml

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: ci-build
2+
3+
# Run this workflow every time a new commit pushed to your repository
4+
on:
5+
push:
6+
branches:
7+
- master
8+
- stable/1.0.x
9+
tags:
10+
- '*'
11+
pull_request:
12+
workflow_dispatch:
13+
14+
env:
15+
IMAGE_NAME: vngr/gemma-brc
16+
DJANGO_SETTINGS_MODULE: brc.conf.jenkins
17+
SECRET_KEY: dummy
18+
DB_USER: postgres
19+
DB_PASSWORD: ''
20+
DEPLOYMENT: brc
21+
22+
jobs:
23+
tests:
24+
runs-on: ubuntu-latest
25+
strategy:
26+
matrix:
27+
postgres: ['10', '11', '12']
28+
29+
name: Tests (PG ${{ matrix.postgres }})
30+
31+
services:
32+
postgres:
33+
image: postgres:${{ matrix.postgres }}
34+
env:
35+
POSTGRES_HOST_AUTH_METHOD: trust
36+
ports:
37+
- 5432:5432
38+
39+
steps:
40+
- uses: actions/checkout@v2
41+
- uses: actions/setup-python@v2
42+
with:
43+
python-version: '3.6'
44+
- uses: actions/setup-node@v2-beta
45+
with:
46+
node-version: '12'
47+
48+
# - name: Install system packages
49+
# run: sudo apt-get install libgdal-dev gdal-bin
50+
51+
- name: Install dependencies
52+
run: pip install -r requirements/jenkins.txt codecov
53+
54+
- name: Build frontend
55+
run: |
56+
npm ci
57+
npm run build
58+
- name: Run tests
59+
run: |
60+
python src/manage.py collectstatic --noinput --link
61+
coverage run src/manage.py test src
62+
63+
- name: Publish coverage report
64+
uses: codecov/codecov-action@v1
65+
66+
docker:
67+
runs-on: ubuntu-latest
68+
name: Docker image build
69+
70+
steps:
71+
- uses: actions/checkout@v2
72+
- name: Determine tag/commit hash
73+
id: vars
74+
run: |
75+
# Strip git ref prefix from version
76+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
77+
# Strip "v" prefix from tag name (if present at all)
78+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
79+
# Use Docker `latest` tag convention
80+
[ "$VERSION" == "master" ] && VERSION=latest
81+
echo ::set-output name=tag::${VERSION}
82+
echo ::set-output name=git_hash::${GITHUB_SHA}
83+
- name: Build the Docker image
84+
run: |
85+
docker build . \
86+
--build-arg COMMIT_HASH=${{ steps.vars.outputs.git_hash }}
87+
# - run: docker image save -o image.tar $IMAGE_NAME:${{ steps.vars.outputs.tag }}
88+
# - name: Store image artifact
89+
# uses: actions/upload-artifact@v2
90+
# with:
91+
# name: docker-image
92+
# path: image.tar
93+
# retention-days: 1
94+
95+
publish:
96+
needs:
97+
- tests
98+
- docker
99+
100+
name: Push Docker image
101+
runs-on: ubuntu-latest
102+
if: github.event_name == 'push' # exclude PRs/forks
103+
104+
steps:
105+
- uses: actions/checkout@v2
106+
# - name: Download built image
107+
# uses: actions/download-artifact@v2
108+
# with:
109+
# name: docker-image
110+
- name: Publish latest image
111+
env: # Or as an environment variable
112+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
113+
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
114+
DEPLOY_BOT_TOKEN: ${{ secrets.DEPLOY_BOT_TOKEN }}
115+
run: |
116+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
117+
if [ "$BRANCH" == "master" ]; then
118+
bash bin/cicd.sh latest no
119+
fi
120+
121+
- name: Publish tagged image
122+
env: # Or as an environment variable
123+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
124+
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
125+
DEPLOY_BOT_TOKEN: ${{ secrets.DEPLOY_BOT_TOKEN }}
126+
run: |
127+
TAG=$(git name-rev --tags --name-only $(git rev-parse HEAD))
128+
if [ "$TAG" != "undefined" ]; then
129+
bash bin/cicd.sh $TAG yes
130+
fi
131+
132+
# - name: Determine tag/commit hash
133+
# id: vars
134+
# run: |
135+
# # Strip git ref prefix from version
136+
# VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
137+
# # Strip "v" prefix from tag name (if present at all)
138+
# [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
139+
# # Use Docker `latest` tag convention
140+
# [ "$VERSION" == "develop" ] && VERSION=latest
141+
# echo ::set-output name=tag::${VERSION}
142+
# - name: Load image
143+
# run: |
144+
# docker image load -i image.tar
145+
# - name: Log into registry
146+
# run: echo "${{ secrets.DOCKER_TOKEN }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
147+
148+
# - name: Push the Docker image
149+
# run: docker push $IMAGE_NAME:${{ steps.vars.outputs.tag }}

.github/workflows/code_quality.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Code quality checks
2+
3+
# Run this workflow every time a new commit pushed to your repository
4+
on:
5+
push:
6+
branches:
7+
- master
8+
- stable/1.0.x
9+
paths:
10+
- '**.py'
11+
pull_request:
12+
paths:
13+
- '**.py'
14+
workflow_dispatch:
15+
16+
jobs:
17+
isort:
18+
name: Code imports
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
- uses: actions/setup-python@v2
24+
with:
25+
python-version: '3.6'
26+
- name: Install dependencies
27+
run: pip install -r requirements/jenkins.txt
28+
- name: Run isort
29+
run: isort --check-only --diff .
30+
31+
black:
32+
name: Code format
33+
runs-on: ubuntu-latest
34+
35+
steps:
36+
- uses: actions/checkout@v2
37+
- uses: actions/setup-python@v2
38+
with:
39+
python-version: '3.6'
40+
- name: Install dependencies
41+
run: pip install -r requirements/jenkins.txt
42+
- name: Run black
43+
run: black --check --diff src docs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: generate-postman-collection
2+
3+
on:
4+
push:
5+
paths:
6+
- "src/openapi.yaml"
7+
- ".github/workflows/generate-postman-collection.yml"
8+
branches:
9+
- '**'
10+
workflow_dispatch:
11+
12+
jobs:
13+
run:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Use Node.js
18+
uses: actions/setup-node@v1
19+
with:
20+
node-version: '12'
21+
- name: Install dependencies
22+
run: npm install -g openapi-to-postmanv2
23+
- name: Create tests folder
24+
run: mkdir -p ./tests/postman
25+
- name: Generate Postman collection
26+
run: openapi2postmanv2 -s ./src/openapi.yaml -o ./tests/postman/collection.json --pretty

.github/workflows/generate-sdks.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: generate-sdks
2+
3+
on:
4+
push:
5+
paths:
6+
- "src/openapi.yaml"
7+
- ".github/workflows/generate-sdks.yml"
8+
branches:
9+
- '**'
10+
workflow_dispatch:
11+
12+
jobs:
13+
run:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Use Node.js
18+
uses: actions/setup-node@v1
19+
with:
20+
node-version: '12'
21+
- name: Install dependencies
22+
run: npm install -g @openapitools/openapi-generator-cli
23+
- name: Validate schema
24+
run: openapi-generator-cli validate -i ./src/openapi.yaml
25+
- name: Generate Java client
26+
run: openapi-generator-cli generate -i ./src/openapi.yaml --global-property=modelTests=false,apiTests=false,modelDocs=false,apiDocs=false \
27+
-o ./sdks/java -g java --additional-properties=dateLibrary=java8,java8=true,optionalProjectFile=false,optionalAssemblyInfo=false
28+
- name: Generate .NET Core client
29+
run: openapi-generator-cli generate -i ./src/openapi.yaml --global-property=modelTests=false,apiTests=false,modelDocs=false,apiDocs=false \
30+
-o ./sdks/netcore -g csharp-netcore --additional-properties=optionalProjectFile=false,optionalAssemblyInfo=false
31+
- name: Generate .NET Full Framework client
32+
run: openapi-generator-cli generate -i ./src/openapi.yaml --global-property=modelTests=false,apiTests=false,modelDocs=false,apiDocs=false \
33+
-o ./sdks/net -g csharp --additional-properties=optionalProjectFile=false,optionalAssemblyInfo=false
34+
- name: Generate Python client
35+
run: openapi-generator-cli generate -i ./src/openapi.yaml --global-property=modelTests=false,apiTests=false,modelDocs=false,apiDocs=false \
36+
-o ./sdks/python -g python --additional-properties=optionalProjectFile=false,optionalAssemblyInfo=false+

.github/workflows/lint-oas.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: lint-oas
2+
3+
on:
4+
push:
5+
paths:
6+
- src/openapi.yaml
7+
- .github/workflows/lint-oas.yml
8+
branches:
9+
- '**'
10+
workflow_dispatch:
11+
12+
jobs:
13+
run:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Use Node.js
18+
uses: actions/setup-node@v1
19+
with:
20+
node-version: '12'
21+
- name: Install spectral
22+
run: npm install -g @stoplight/spectral
23+
- name: Run OAS linter
24+
run: spectral lint ./src/openapi.yaml

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,8 @@ local.py
3131
.env
3232

3333
docs/_build
34+
35+
# Statics generated by Workflows
36+
/tests/postman
37+
/sdks/
38+
openapitools.json

.spectral.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extends: spectral:oas

.travis.yml

-55
This file was deleted.

Dockerfile

+5
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ COPY ./bin/runtests.sh /runtests.sh
5858
COPY --from=frontend-build /app/src/brc/static/fonts /app/src/brc/static/fonts
5959
COPY --from=frontend-build /app/src/brc/static/css /app/src/brc/static/css
6060
COPY ./src /app/src
61+
ARG COMMIT_HASH
62+
ENV GIT_SHA=${COMMIT_HASH}
63+
6164
RUN mkdir /app/log && rm /app/src/brc/conf/test.py
6265
CMD ["/runtests.sh"]
6366

@@ -94,6 +97,8 @@ COPY --from=frontend-build /app/src/brc/static/fonts /app/src/brc/static/fonts
9497
COPY --from=frontend-build /app/src/brc/static/css /app/src/brc/static/css
9598
COPY ./src /app/src
9699
COPY ./docs /app/docs
100+
ARG COMMIT_HASH
101+
ENV GIT_SHA=${COMMIT_HASH}
97102

98103
ENV DJANGO_SETTINGS_MODULE=brc.conf.docker
99104

0 commit comments

Comments
 (0)