-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from CodeForAfrica/ch-setup-ci-cd
Chore setup continuous integration/continuous delivery
- Loading branch information
Showing
12 changed files
with
256 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Required | ||
TWOOPSTRACKER_DATABASE_URL= | ||
TWOOPSTRACKER_SECRET_KEY= | ||
|
||
# End of Required | ||
|
||
# Optional | ||
TWOOPSTRACKER_ALLOWED_HOSTS= | ||
TWOOPSTRACKER_DEBUG=False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Desktop (please complete the following information):** | ||
- OS: [e.g. iOS] | ||
- Browser [e.g. chrome, safari] | ||
- Version [e.g. 22] | ||
|
||
**Smartphone (please complete the following information):** | ||
- Device: [e.g. iPhone6] | ||
- OS: [e.g. iOS8.1] | ||
- Browser [e.g. stock browser, safari] | ||
- Version [e.g. 22] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
## Description | ||
|
||
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. | ||
|
||
Fixes # (issue) | ||
|
||
## Type of change | ||
|
||
Please delete options that are not relevant. | ||
|
||
- [ ] New feature (non-breaking change which adds functionality) | ||
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) | ||
- [ ] Bug fix (non-breaking change which fixes an issue) | ||
- [ ] Chore (non-breaking change which does not add visible functionality but improves code quality) | ||
- [ ] This change requires a documentation update | ||
|
||
## Screenshots | ||
|
||
|
||
## Checklist: | ||
|
||
- [ ] My code follows the style guidelines of this project | ||
- [ ] I have performed a self-review of my own code | ||
- [ ] I have commented my code, particularly in hard-to-understand areas | ||
- [ ] I have made corresponding changes to the documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Dokku CD | ||
on: | ||
push: | ||
branches: [main] | ||
env: | ||
DOKKU_REMOTE_BRANCH: "master" | ||
DOKKU_REMOTE_URL: "ssh://[email protected]/twoopstracker" | ||
GIT_PUSH_FLAGS: "--force" | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- 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: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
|
||
- name: Build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: true | ||
tags: codeforafrica/twoopstracker:latest | ||
target: python-app-ci | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new | ||
|
||
- name: Move cache | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | ||
- name: Push to Dokku | ||
uses: dokku/[email protected] | ||
with: | ||
branch: ${{ env.DOKKU_REMOTE_BRANCH }} | ||
git_push_flags: ${{ env.GIT_PUSH_FLAGS }} | ||
git_remote_url: ${{ env.DOKKU_REMOTE_URL }} | ||
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
jobs: | ||
docker: | ||
name: Build, Lint & Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- 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 | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: false | ||
tags: codeforafrica/twoopstracker:latest | ||
target: python-app-ci | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new | ||
|
||
# This ugly bit is necessary if you don't want your cache to grow forever | ||
# till it hits GitHub's limit of 5GB. | ||
# 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 app | ||
run: | | ||
echo "TWOOPSTRACKER_SECRET_KEY=${{ secrets.TWOOPSTRACKER_SECRET_KEY }}" >> .env | ||
echo "TWOOPSTRACKER_SENTRY_DSN=${{ secrets.TWOOPSTRACKER_SENTRY_DSN }}" >> .env | ||
make runci | ||
- name: Run Lint | ||
run: make lint | ||
|
||
- name: Test app | ||
run: make test | ||
|
||
- name: Stop app | ||
run: make stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
COMPOSE = docker-compose | ||
COMPOSE_BUILD_ENV = COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 | ||
COMPOSE_BUILD_FLAGS = --progress=plain | ||
|
||
build: | ||
$(COMPOSE_BUILD_ENV) $(COMPOSE) build $(COMPOSE_BUILD_FLAGS) | ||
|
||
run: | ||
$(COMPOSE_BUILD_ENV) $(COMPOSE) up -d | ||
|
||
runci: | ||
$(COMPOSE_BUILD_ENV) $(COMPOSE) up -d app | ||
|
||
enter: | ||
$(COMPOSE) exec app bash | ||
|
||
createsuperuser: | ||
$(COMPOSE) exec app python manage.py createsuperuser | ||
|
||
lint: | ||
$(COMPOSE) exec -T app pre-commit run --all-files | ||
|
||
test: | ||
$(COMPOSE) exec -T app python manage.py test | ||
|
||
stop: | ||
$(COMPOSE) down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Django==3.2.8 | ||
environs[django]==9.3.4 | ||
greenlet==1.1.2 | ||
gunicorn[gevent, setproctitle]==20.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ black==21.9b0 | |
flake8==4.0.1 | ||
isort==5.9.3 | ||
mypy==0.910 | ||
pre-commit==2.15.0 | ||
psycopg2-binary==2.9.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
-r requirements-all.txt | ||
psycopg2==2.9.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters