aboutsummaryrefslogtreecommitdiff
path: root/.github
diff options
context:
space:
mode:
Diffstat (limited to '.github')
-rw-r--r--.github/docker/Dockerfile-backend17
-rw-r--r--.github/docker/Dockerfile-frontend7
-rw-r--r--.github/docker/docker-compose.yml22
-rw-r--r--.github/workflows/deploy.yml38
-rw-r--r--.github/workflows/test.yml58
5 files changed, 142 insertions, 0 deletions
diff --git a/.github/docker/Dockerfile-backend b/.github/docker/Dockerfile-backend
new file mode 100644
index 0000000..82ed29f
--- /dev/null
+++ b/.github/docker/Dockerfile-backend
@@ -0,0 +1,17 @@
+FROM golang:1.16
+
+RUN apt-get update && \
+ DEBIAN_FRONTEND=noninteractive apt-get install -qq \
+ git \
+ pkg-config \
+ libpcap-dev \
+ libhyperscan-dev
+
+WORKDIR /caronte
+
+COPY . ./
+
+RUN go mod download && \
+ go build
+
+ENTRYPOINT go test -v -race -covermode=atomic
diff --git a/.github/docker/Dockerfile-frontend b/.github/docker/Dockerfile-frontend
new file mode 100644
index 0000000..5cd82b0
--- /dev/null
+++ b/.github/docker/Dockerfile-frontend
@@ -0,0 +1,7 @@
+FROM node:16
+
+WORKDIR /caronte-frontend
+
+COPY ./frontend ./
+
+RUN yarn install && yarn build
diff --git a/.github/docker/docker-compose.yml b/.github/docker/docker-compose.yml
new file mode 100644
index 0000000..ddaf839
--- /dev/null
+++ b/.github/docker/docker-compose.yml
@@ -0,0 +1,22 @@
+version: "3.7"
+services:
+
+ mongo:
+ image: mongo:4.4
+
+ test-backend:
+ build:
+ context: ../../
+ dockerfile: .github/docker/Dockerfile-backend
+ image: caronte-test-backend
+ depends_on:
+ - mongo
+ environment:
+ MONGO_HOST: mongo
+ MONGO_PORT: 27017
+
+ test-frontend:
+ build:
+ context: ../../
+ dockerfile: .github/docker/Dockerfile-frontend
+ image: caronte-test-frontend
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
new file mode 100644
index 0000000..38f302f
--- /dev/null
+++ b/.github/workflows/deploy.yml
@@ -0,0 +1,38 @@
+name: Deploy
+on:
+ release:
+ types:
+ - published
+env:
+ REGISTRY: ghcr.io
+ IMAGE_NAME: caronte
+jobs:
+ build_push_docker:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ packages: write
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v2
+ - name: Log in to the Container registry
+ uses: docker/login-action@v1
+ with:
+ registry: ${{ env.REGISTRY }}
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+ - name: Extract metadata for Docker
+ id: meta
+ uses: docker/metadata-action@v3
+ with:
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
+ - name: Build and push Docker image
+ id: docker_build
+ uses: docker/build-push-action@v2
+ with:
+ context: .
+ push: true
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
+ - name: Image digests
+ run: echo ${{ steps.docker_build.outputs.digest }}
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..95b44fc
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,58 @@
+name: Test
+on: [push, pull_request]
+jobs:
+ test_backend:
+ name: Build and test backend
+ runs-on: ubuntu-latest
+ services:
+ mongo:
+ image: mongo:4.4
+ ports:
+ - 27017:27017
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up Go
+ uses: actions/setup-go@v2
+ with:
+ go-version: 1.16
+ - name: Install dependencies
+ run: sudo apt-get install pkg-config libpcap-dev libhyperscan-dev
+ - name: Test backend
+ run: go test -v -race -coverprofile=coverage.txt -covermode=atomic
+ - name: Upload coverage
+ run: bash <(curl -s https://codecov.io/bash)
+ build_frontend:
+ name: Build frontend
+ runs-on: ubuntu-latest
+ defaults:
+ run:
+ working-directory: frontend
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up Node.js
+ uses: actions/setup-node@v2
+ with:
+ node-version: 14.x
+ - name: Install dependencies
+ run: yarn install
+ - name: Build frontend
+ run: yarn build
+ test_docker:
+ name: Build and test docker environment
+ runs-on: ubuntu-latest
+ env:
+ COMPOSE_FILE: .github/docker/docker-compose.yml
+ steps:
+ - uses: actions/checkout@v2
+ - name: Pull docker images
+ run: docker-compose pull mongo
+ - name: Build docker backend
+ run: docker-compose build test-backend
+ - name: Build docker frontend
+ run: docker-compose build test-frontend
+ - name: Start MongoDB
+ run: docker-compose up -d mongo
+ - name: Test docker backend
+ run: docker-compose run test-backend
+ - name: Destroy containers
+ run: docker-compose down