diff --git a/.github/workflows/labyrinth.yml b/.github/workflows/labyrinth.yml index 7aafb242..0a5c89ec 100644 --- a/.github/workflows/labyrinth.yml +++ b/.github/workflows/labyrinth.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 2dbf24f3..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: release - -on: - workflow_dispatch: - push: - tags: - '[0-9]+.[0-9]+.[0-9]+' - -jobs: - web-client: - runs-on: ubuntu-latest - steps: - - name: Check out repository - uses: actions/checkout@v2 - - name: Log in to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v3 - with: - images: julianarz/labyrinth-web-client - tags: | - type=ref,priority=600,event=branch - type=match,priority=600,pattern=\d.\d.\d - type=raw,priority=200,value=latest - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: ./web-client - file: ./web-client/Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - backend: - runs-on: ubuntu-latest - steps: - - name: Check out repository - uses: actions/checkout@v2 - - name: Log in to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v3 - with: - images: julianarz/labyrinth-backend - tags: | - type=ref,priority=600,event=branch - type=match,priority=600,pattern=\d.\d.\d - type=raw,priority=200,value=latest - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: ./ - file: ./docker/backend.Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/docker/backend.Dockerfile b/docker/backend.Dockerfile index 0f56d220..56f394e8 100644 --- a/docker/backend.Dockerfile +++ b/docker/backend.Dockerfile @@ -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 diff --git a/web-client/Dockerfile b/web-client/Dockerfile index 07a6766e..3caf27aa 100644 --- a/web-client/Dockerfile +++ b/web-client/Dockerfile @@ -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 diff --git a/web-client/package.json b/web-client/package.json index 6511d8d0..dcd885d8 100644 --- a/web-client/package.json +++ b/web-client/package.json @@ -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": {