Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pure docker workflow #26

Merged
merged 6 commits into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 44 additions & 75 deletions .github/workflows/labyrinth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,103 +11,72 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Set up node
uses: actions/setup-node@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
node-version: "16.x"
- name: Install dependencies
run: |
npm ci
install: true
- name: Lint
run: |
npm run lint
docker build --target lint .
- name: Run tests
run: |
npm run test:unit
- name: Build web-client
run: |
npm run build
- name: Archive web-client
uses: actions/upload-artifact@v2
with:
name: webClient
path: |
dist/
docker/
docker build --target test .

algolibs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./algolibs
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Setup cmake
uses: lukka/get-cmake@latest
- name: Run cmake and build shared library
run: |
export CC=gcc-9
export CXX=g++-9
mkdir builds
cmake -S. -Bbuilds/shared -DCMAKE_BUILD_TYPE=RELEASE
cmake --build builds/shared
mkdir -p ../backend/instance/lib/
cp builds/shared/solvers/*.so ../backend/instance/lib/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Run tests
run: |
mkdir ../test-results
cd builds/shared/test/
ctest -V
mv all_tests.xml ../../../../test-results/algolibs-results.xml
cd ../../../
- name: Archive shared library
uses: actions/upload-artifact@v1
with:
name: sharedLib
path: backend/instance/lib/
docker build --target algolibs-test --file docker/backend.Dockerfile .

backend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
needs: [web-client, algolibs]
needs: [algolibs]
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m venv venv
. venv/bin/activate
pip install --upgrade pip
pip install -r dev-requirements.txt
install: true
- name: Lint
run: |
. venv/bin/activate
flake8 . --count --max-line-length=120 --max-complexity=10 --show-source --statistics --exclude __pycache__,venv
- name: Restore shared library artifact
uses: actions/download-artifact@v1
with:
name: sharedLib
path: backend/instance/lib/
docker build --target lint --file docker/backend.Dockerfile .
- name: Run tests
run: |
. venv/bin/activate
pytest . --junitxml=../test-results/backend-results.xml --cov=backend --cov-report=xml:../test-results/backend-coverage.xml
- name: Archive deployment
uses: actions/upload-artifact@v2
docker build --target test --file docker/backend.Dockerfile .
release:
runs-on: ubuntu-latest
needs: [web-client, algolibs, backend]
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push web-client image
uses: docker/build-push-action@v2
with:
context: ./web-client
file: ./web-client/Dockerfile
push: true
tags: julianarz/labyrinth-web-client:latest
- name: Build and push backend image
uses: docker/build-push-action@v2
with:
name: deployment
path: |
backend/instance
backend/static
backend/labyrinth
backend/requirements.txt
backend/labyrinth_main.py
backend/uwsgi-docker.ini
backend/Dockerfile
context: ./
file: ./docker/backend.Dockerfile
push: true
tags: julianarz/labyrinth-backend:latest
64 changes: 0 additions & 64 deletions .github/workflows/release.yml

This file was deleted.

8 changes: 6 additions & 2 deletions docker/backend.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,20 @@ COPY backend/instance ./instance
RUN rm -rf instance/lib && mkdir instance/lib
COPY --from=algolibs-release /usr/src/algolibs/build/solvers/*.so instance/lib/

FROM base as test
FROM base as dev

COPY backend/dev-requirements.txt .
RUN pip install --no-cache-dir -r dev-requirements.txt

# lint
FROM dev as lint
RUN flake8 . --count --max-line-length=120 --max-complexity=10 --show-source --statistics --exclude __pycache__,venv

# test
RUN pytest . --junitxml=../test-results/backend-results.xml --cov=backend --cov-report=xml:../test-results/backend-coverage.xml
FROM dev as test
COPY backend/pytest.ini backend/conftest.py ./
COPY backend/tests ./tests
RUN pytest .

FROM base as release

Expand Down
9 changes: 7 additions & 2 deletions web-client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ FROM node:16 as base
WORKDIR /usr/src/web-client

# copy everything but .dockerignore
COPY . ./
COPY package.json package-lock.json ./

RUN npm ci

COPY . ./

FROM base as test

RUN npm run lint
RUN npm run test:unit

FROM base as lint

RUN npm run lint

FROM base as build

RUN npm run build
Expand Down
2 changes: 1 addition & 1 deletion web-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit --maxWorkers=4",
"lint": "vue-cli-service lint",
"lint": "vue-cli-service lint --no-fix",
"debug-build": "vue-cli-service build --mode development"
},
"dependencies": {
Expand Down
Loading