Skip to content

Commit

Permalink
[#1] Workflow tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dedenbangkit committed Sep 20, 2023
1 parent 65a0fd2 commit 5b09a6e
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 41 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Build & Test
on:
push:
branches:
- main
- feature*
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build and Test
run: |
./ci/build.sh
13 changes: 13 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.10.7

WORKDIR /usr/src/app

COPY . .

RUN set -e; \
pip -q install --upgrade pip && \
pip -q install --no-cache-dir -r requirements.txt && \
pip check


CMD ["sh", "run.sh"]
3 changes: 3 additions & 0 deletions backend/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

flake8
3 changes: 3 additions & 0 deletions backend/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

python main.py
46 changes: 46 additions & 0 deletions ci/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
#shellcheck disable=SC2039

set -exuo pipefail

IMAGE_PREFIX="eu.gcr.io/akvo-lumen/idh-idc"
CI_COMMIT=$(git rev-parse --short "$GITHUB_SHA")

echo "CI_COMMIT=${CI_COMMIT}"

dc() {
docker compose \
--ansi never \
"$@"
}

frontend_build() {

echo "PUBLIC_URL=/" >frontend/.env

# Code Quality and Build Folder
sed 's/"warn"/"error"/g' <frontend/.eslintrc.json >frontend/.eslintrc.prod.json

dc -f docker-compose.yml run \
--rm \
--no-deps \
frontend \
sh release.sh

docker build \
--tag "${IMAGE_PREFIX}/frontend:latest" \
--tag "${IMAGE_PREFIX}/frontend:${CI_COMMIT}" frontend

}

backend_build() {

docker build \
--tag "${IMAGE_PREFIX}/backend:latest" \
--tag "${IMAGE_PREFIX}/backend:${CI_COMMIT}" backend
}

backend_build
frontend_build

docker-compose -f docker-compose.test.yml run -T ./check.sh
40 changes: 0 additions & 40 deletions docker-compose.ci.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
volumes:
- ./backend:/app:delegated
working_dir: /app
command: "pytest -rP"
command: ["./check.sh"]
environment:
- DATABASE_URL=postgresql://idc:password@db:5432/idh_idc
- SKIP_MIGRATION=yes
Expand Down
10 changes: 10 additions & 0 deletions frontend/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
#shellcheck disable=SC2039

set -euo pipefail

yarn install --no-progress --frozen-lock
yarn eslint --config .eslintrc.prod.json src --ext .js,.jsx
yarn prettier --check src/
yarn test:ci
yarn build

0 comments on commit 5b09a6e

Please sign in to comment.