Skip to content
Draft
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
105 changes: 0 additions & 105 deletions .github/labels.yml

This file was deleted.

22 changes: 0 additions & 22 deletions .github/workflows/label-importer.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/on-push-main-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
needs: tests
name: "Generate changelog"
uses: ./.github/workflows/generate-changelog.yaml

docs:
needs: generate-changelog
name: "Build and publish docs"
Expand Down
17 changes: 12 additions & 5 deletions .github/workflows/publish-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ on:

env:
IMAGE_REGISTRY: ghcr.io
REGISTRY_USER: $GITHUB_ACTOR
API_IMAGE: ghcr.io/equinor/template-fastapi-react/api
NGINX_IMAGE: ghcr.io/equinor/template-fastapi-react/nginx

Expand All @@ -26,8 +25,12 @@ jobs:
with:
fetch-depth: 2

- name: "Login to image registry"
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login $IMAGE_REGISTRY -u $GITHUB_ACTOR --password-stdin
- name: "Login to GitHub Container Registry"
uses: docker/login-action@v3
with:
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: "Build web"
run: |
Expand Down Expand Up @@ -60,8 +63,12 @@ jobs:
with:
fetch-depth: 2

- name: "Login to image registry"
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login $IMAGE_REGISTRY -u $GITHUB_ACTOR --password-stdin
- name: "Login to GitHub Container Registry"
uses: docker/login-action@v3
with:
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: "Build API"
run: |
Expand Down
112 changes: 69 additions & 43 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,72 +10,94 @@ on:
required: false

env:
IMAGE_REGISTRY: ghcr.io
REGISTRY_USER: $GITHUB_ACTOR
API_IMAGE: ghcr.io/equinor/template-fastapi-react/api
WEB_IMAGE: ghcr.io/equinor/template-fastapi-react/web
REGISTRY: ghcr.io
API_IMAGE_NAME: api

jobs:
api-unit-tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./api
steps:
- uses: actions/checkout@v4
- name: "Setup: checkout repository"
uses: actions/checkout@v4

- name: Login to image registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login $IMAGE_REGISTRY -u $GITHUB_ACTOR --password-stdin
- name: "Setup: install poetry"
run: pipx install poetry

- name: Build API image
run: |
docker pull $API_IMAGE
docker build --target development --tag api-development ./api # TODO: --cache-from $API_IMAGE
- name: "Setup: add python"
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "poetry"

- name: Pytest Unit tests
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml run --rm api pytest --unit
- name: "Run: pytest unit tests"
run: poetry run pytest --unit

api-integration-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Setup: checkout repository"
uses: actions/checkout@v4

- name: "Setup: Set image name"
run: echo "API_IMAGE=${{ env.REGISTRY }}/${{ github.repository }}/${{ env.API_IMAGE_NAME }}" >> "$GITHUB_ENV"

- name: Login to image registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login $IMAGE_REGISTRY -u $GITHUB_ACTOR --password-stdin
- name: "Setup: Login to GitHub Container Registry"
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# - name: "Setup: Docker Buildx"
# uses: docker/setup-buildx-action@v3

- name: "Setup: Build API image"
uses: docker/build-push-action@v6
with:
context: ./api
target: development
load: true
tags: ${{ env.API_IMAGE }}:dev
cache-from: type=registry,ref=${{ env.API_IMAGE }}:dev
# cache-to: type=registry,ref=${{ env.API_IMAGE }}:dev,mode=max

- name: Build API image
run: |
docker pull $API_IMAGE
docker build --target development --tag api-development ./api # TODO: --cache-from $API_IMAGE
- name: "Run: Integration tests (pytest)"
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml run --rm api python -m pytest --integration

- name: BDD Integration tests
- name: "Run: Integration tests (behave)"
if: ${{ false }} # disable for now
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml run api behave

- name: Pytest Integration tests
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml run --rm api pytest --integration

web-tests:
runs-on: ubuntu-latest
if: ${{ false }} # disable for now as they do not currently work
steps:
- uses: actions/checkout@v4

- name: Login to image registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login $IMAGE_REGISTRY -u $GITHUB_ACTOR --password-stdin
- name: "Setup: checkout repository"
uses: actions/checkout@v4

- name: Build Web Image
run: |
docker pull $WEB_IMAGE
docker build --cache-from $WEB_IMAGE --target development --tag web-dev ./web
- name: "Setup: Build web image"
uses: docker/build-push-action@v6
with:
context: ./web
target: development
load: true
tags: web:dev

- name: Run Web tests
if: ${{ false }} # disable for now as they do not currently work
- name: "Run: Web tests"
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml run --rm web yarn test

docs-tests:
name: test-docs
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./documentation
steps:
# If you know your docs does not rely on anything outside of the documentation folder, the commented out code below can be used to only test the docs build if the documentation folder changes.
- name: Checkout GitHub Action
- name: "Setup: checkout repository"
uses: actions/checkout@v4
# with:
# fetch-depth: 0
Expand All @@ -85,17 +107,21 @@ jobs:
# shell: bash
# run: echo "changes=$(git diff --name-only $(git merge-base HEAD origin/main) HEAD | grep documentation/ | wc -l)" >> $GITHUB_OUTPUT

- name: Setup node
- name: "Setup: node"
if: ${{ false }}
# if: steps.docs-changes.outputs.changes > 0
id: setup-node
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
cache-dependency-path: documentation/yarn.lock

- name: Install dependencies and build website
# if: steps.docs-changes.outputs.changes > 0
run: |
cd documentation
yarn install --frozen-lockfile
yarn build
- name: "Setup: Install dependencies"
id: install-deps
if: steps.setup-node.outcome == 'success'
run: yarn install --frozen-lockfile

- name: "Run: Build docs"
if: steps.install-deps.outcome == 'success'
run: yarn build
13 changes: 0 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,3 @@ repos:
name: "Lint : biome (ts/js)"
additional_dependencies: ["@biomejs/biome@1.9.4"]
args: ["--config-path", "web"]

- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
- id: codespell
name: "Lint : spelling"
description: Checks for common misspellings in text files.
entry: codespell --toml=api/pyproject.toml
exclude: documentation/docs/changelog/changelog.md
language: python
types: [text]
additional_dependencies:
- tomli
6 changes: 3 additions & 3 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=linux/amd64 python:3.13-slim AS base
FROM python:3.13-slim AS base
WORKDIR /code
CMD ["/code/src/init.sh", "api"]
EXPOSE 5000
Expand All @@ -7,8 +7,8 @@ ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/code

RUN pip install --upgrade pip && \
pip install poetry && \
poetry config virtualenvs.create false
pip install poetry && \
poetry config virtualenvs.create false

COPY pyproject.toml pyproject.toml
COPY poetry.lock poetry.lock
Expand Down
Loading