Skip to content

Commit 4cde430

Browse files
committed
ci: test
1 parent 2694d11 commit 4cde430

File tree

2 files changed

+47
-45
lines changed

2 files changed

+47
-45
lines changed

.github/workflows/tests.yaml

+41-41
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ on:
1111

1212
env:
1313
REGISTRY: ghcr.io
14-
API_IMAGE_PATH: ${{ github.repository }}/api
15-
WEB_IMAGE_PATH: ${{ github.repository }}/web
14+
API_IMAGE_NAME: api
1615

1716
jobs:
1817
api-unit-tests:
@@ -42,6 +41,9 @@ jobs:
4241
- name: "Setup: checkout repository"
4342
uses: actions/checkout@v4
4443

44+
- name: "Setup: Set image name"
45+
run: echo "API_IMAGE=${{ env.REGISTRY }}/${{ github.repository }}/${{ env.API_IMAGE_NAME }}" >> "$GITHUB_ENV"
46+
4547
- name: "Setup: Login to GitHub Container Registry"
4648
uses: docker/login-action@v3
4749
with:
@@ -51,56 +53,51 @@ jobs:
5153

5254
# - name: "Setup: Docker Buildx"
5355
# uses: docker/setup-buildx-action@v3
54-
#
55-
# - name: "Setup: Build API image"
56-
# uses: docker/build-push-action@v6
57-
# with:
58-
# context: ./api
59-
# target: development
60-
# load: true
61-
# tags: ${{ env.REGISTRY }}/${{ env.API_IMAGE_PATH }}:buildcache
62-
# cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.API_IMAGE_PATH }}:buildcache
63-
64-
# - name: Build API image
65-
# run: |
66-
# docker pull $API_IMAGE
67-
# docker build --target development --tag api-development ./api # TODO: --cache-from $API_IMAGE
68-
69-
- name: Pytest Integration tests
56+
57+
- name: "Setup: Build API image"
58+
uses: docker/build-push-action@v6
59+
with:
60+
context: ./api
61+
target: development
62+
load: true
63+
tags: ${{ env.API_IMAGE }}:dev
64+
cache-from: type=registry,ref=${{ env.API_IMAGE }}:dev
65+
# cache-to: type=registry,ref=${{ env.API_IMAGE }}:dev,mode=max
66+
67+
- name: "Run: Integration tests (pytest)"
7068
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml run --rm api python -m pytest --integration
7169

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

7674
web-tests:
7775
runs-on: ubuntu-latest
76+
# if: ${{ false }} # disable for now as they do not currently work
7877
steps:
79-
- uses: actions/checkout@v4
78+
- name: "Setup: checkout repository"
79+
uses: actions/checkout@v4
8080

81-
- name: "Login to GitHub Container Registry"
82-
uses: docker/login-action@v3
81+
- name: "Setup: Build web image"
82+
uses: docker/build-push-action@v6
8383
with:
84-
registry: ${{ env.REGISTRY }}
85-
username: ${{ github.actor }}
86-
password: ${{ secrets.GITHUB_TOKEN }}
87-
88-
- name: Build Web Image
89-
run: |
90-
docker pull ${REGISTRY}/${WEB_IMAGE_PATH}
91-
docker build --cache-from ${REGISTRY}/${WEB_IMAGE_PATH} --target development --tag web-dev ./web
84+
context: ./web
85+
target: development
86+
load: true
87+
tags: web:dev
9288

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

9792
docs-tests:
9893
name: test-docs
9994
runs-on: ubuntu-latest
100-
95+
defaults:
96+
run:
97+
working-directory: ./documentation
10198
steps:
10299
# 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.
103-
- name: Checkout GitHub Action
100+
- name: "Setup: checkout repository"
104101
uses: actions/checkout@v4
105102
# with:
106103
# fetch-depth: 0
@@ -110,17 +107,20 @@ jobs:
110107
# shell: bash
111108
# run: echo "changes=$(git diff --name-only $(git merge-base HEAD origin/main) HEAD | grep documentation/ | wc -l)" >> $GITHUB_OUTPUT
112109

113-
- name: Setup node
110+
- name: "Setup: node"
114111
# if: steps.docs-changes.outputs.changes > 0
112+
id: setup-node
115113
uses: actions/setup-node@v4
116114
with:
117115
node-version: 20
118116
cache: yarn
119117
cache-dependency-path: documentation/yarn.lock
120118

121-
- name: Install dependencies and build website
122-
# if: steps.docs-changes.outputs.changes > 0
123-
run: |
124-
cd documentation
125-
yarn install --frozen-lockfile
126-
yarn build
119+
- name: "Setup: Install dependencies"
120+
id: install-deps
121+
if: steps.setup-node.outcome == 'success'
122+
run: yarn install --frozen-lockfile
123+
124+
- name: "Run: Build docs"
125+
if: steps.install-deps.outcome == 'success'
126+
run: yarn build

docker-compose.ci.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
services:
22
api:
3-
image: ghcr.io/equinor/template-fastapi-react/api:latest
4-
# image: api-development
3+
image: ghcr.io/equinor/template-fastapi-react/api:dev
54
build:
65
target: development
76
environment:
@@ -13,11 +12,14 @@ services:
1312
MONGODB_PORT: 27017
1413
SECRET_KEY: sg9aeUM5i1JO4gNN8fQadokJa3_gXQMLBjSGGYcfscs=
1514
AUTH_ENABLED: "False"
16-
depends_on:
17-
- db
1815
links:
1916
- db
2017

18+
nginx:
19+
image: web:dev
20+
build:
21+
target: development
22+
2123
db:
2224
environment:
2325
MONGO_INITDB_ROOT_USERNAME: root

0 commit comments

Comments
 (0)