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

Fix integration tests #593

Merged
merged 7 commits into from
Nov 7, 2024
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
38 changes: 3 additions & 35 deletions .github/workflows/alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "Alpha Build"

on:
push:
branches: [v552/fix-docker-build]
branches: [v552/integration]

jobs:
frontend:
Expand Down Expand Up @@ -125,41 +125,9 @@ jobs:
- uses: actions/checkout@v4
- name: Run Integration Tests
run: docker compose -f ./integration/docker-compose.ci.alpha.yml up --exit-code-from cypress
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: always()
with:
name: Test videos
path: integration/cypress/videos
path: integration/cypress/videos/
retention-days: 14

trivy:
runs-on: ubuntu-latest
needs: [frontend, backend, marketing]
steps:
- name: Trivy - Frontend
uses: aquasecurity/trivy-action@master
with:
image-ref: retrospected/frontend:alpha
format: "table"
exit-code: "1"
ignore-unfixed: true
vuln-type: "os,library"
severity: "CRITICAL"
- name: Trivy - Backend
uses: aquasecurity/trivy-action@master
with:
image-ref: retrospected/backend:alpha
format: "table"
exit-code: "1"
ignore-unfixed: true
vuln-type: "os,library"
severity: "CRITICAL"
- name: Trivy - Marketing
uses: aquasecurity/trivy-action@master
with:
image-ref: retrospected/marketing:alpha
format: "table"
exit-code: "1"
ignore-unfixed: true
vuln-type: "os,library"
severity: "CRITICAL"
36 changes: 2 additions & 34 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,41 +153,9 @@ jobs:
- uses: actions/checkout@v4
- name: Run Integration Tests
run: docker compose -f ./integration/docker-compose.ci.canary.yml up --exit-code-from cypress
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: always()
with:
name: Test videos
path: integration/cypress/videos
path: integration/cypress/videos/
retention-days: 14

trivy:
runs-on: ubuntu-latest
needs: [frontend, backend, marketing]
steps:
- name: Trivy - Frontend
uses: aquasecurity/trivy-action@master
with:
image-ref: retrospected/frontend:canary
format: "table"
exit-code: "1"
ignore-unfixed: true
vuln-type: "os,library"
severity: "CRITICAL"
- name: Trivy - Backend
uses: aquasecurity/trivy-action@master
with:
image-ref: retrospected/backend:canary
format: "table"
exit-code: "1"
ignore-unfixed: true
vuln-type: "os,library"
severity: "CRITICAL"
- name: Trivy - Marketing
uses: aquasecurity/trivy-action@master
with:
image-ref: retrospected/marketing:canary
format: "table"
exit-code: "1"
ignore-unfixed: true
vuln-type: "os,library"
severity: "CRITICAL"
20 changes: 20 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Integration only (test)"

on:
push:
branches: [v552/integration]

jobs:
integration:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Run Integration Tests
run: docker compose -f ./integration/docker-compose.ci.alpha.yml up --exit-code-from cypress
- uses: actions/upload-artifact@v4
if: always()
with:
name: Test videos
path: integration/cypress/videos/
retention-days: 14
4 changes: 2 additions & 2 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ jobs:
- uses: actions/checkout@v4
- name: Run Integration Tests
run: docker compose -f ./integration/docker-compose.ci.master.yml up --exit-code-from cypress
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: always()
with:
name: Test videos
path: integration/cypress/videos
path: integration/cypress/videos/
retention-days: 14
17 changes: 0 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,6 @@ marketing-build:
docker build -f ./marketing/Dockerfile -t retrospected/marketing:local ./marketing
docker run -it --rm -p 3333:80 retrospected/marketing:local

install-trivy:
brew install trivy

trivy-f:
docker build -f ./frontend/Dockerfile -t retrospected/frontend:trivy ./frontend
trivy image retrospected/frontend:trivy --security-checks vuln

trivy-b:
docker build -f ./backend/Dockerfile -t retrospected/backend:trivy ./backend
trivy image retrospected/backend:trivy --security-checks vuln

trivy:
docker build -f ./backend/Dockerfile -t retrospected/backend:trivy ./backend
docker build -f ./frontend/Dockerfile -t retrospected/frontend:trivy ./frontend
trivy image retrospected/backend:trivy --security-checks vuln
trivy image retrospected/frontend:trivy --security-checks vuln

translate:
crowdin push sources
crowdin pre-translate --method=mt --engine-id=316468 -l=fr -l=nl -l=ar -l=de -l=it -l=ja -l=uk
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ This will run a demo version, which you can turn into a fully licenced version b

## Versions History

### Version 5.5.2

- Fix integration tests by adding a health check so that the frontend does not start before the backend is ready
- Remove Trivy from the CI pipeline, as it was just not working at all

### Version 5.5.1

- Hardcode a licence for the Ministère de l'intérieur (France) for their self-hosted instance
Expand Down
3 changes: 3 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ WORKDIR /usr/src/backend

ENV NODE_ENV=production

RUN apk update
RUN apk add curl

COPY ./yarn.lock ./
COPY ./package.json ./

Expand Down
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@retrospected/backend",
"version": "5.5.1",
"version": "5.5.2",
"license": "GNU GPLv3",
"private": true,
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@retrospected/docs",
"version": "5.5.1",
"version": "5.5.2",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@retrospected/frontend",
"version": "5.5.1",
"version": "5.5.2",
"license": "GNU GPLv3",
"private": true,
"type": "module",
Expand Down
5 changes: 5 additions & 0 deletions integration/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ local:
yarn test
docker-compose down

local-compose:
docker build -f ../backend/Dockerfile -t retro-backend:local ../backend
docker build -f ../frontend/Dockerfile -t retro-frontend:local ../frontend
docker-compose -f ./docker-compose.local.local.yml up --exit-code-from cypress

alpha:
docker-compose rm -s -f -v
docker-compose -f ./docker-compose.ci.alpha.yml pull
Expand Down
3 changes: 3 additions & 0 deletions integration/cypress/e2e/test.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ describe('Post workflow', () => {
it('Should allow to login as anonymous and write a post', () => {
cy.visit('/');

// Wait for the page to load (and the server to be ready)
cy.get('#content').get('h1', { timeout }).should('contain', 'Welcome!');

// Login anonymously
get('login-anonymous').click();

Expand Down
10 changes: 7 additions & 3 deletions integration/docker-compose.ci.alpha.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3'
services:
cypress:
image: "cypress/included:12.6.0"
Expand Down Expand Up @@ -29,11 +28,15 @@ services:
image: retrospected/backend:alpha
depends_on:
- redis
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3201/healthz"]
interval: 2s
timeout: 5s
retries: 30
environment:
SELF_HOSTED_ADMIN: '[email protected]'
DB_PASSWORD: some-password
SESSION_SECRET: im-a-secret

restart: unless-stopped
logging:
driver: 'json-file'
Expand All @@ -43,7 +46,8 @@ services:
frontend:
image: retrospected/frontend:alpha
depends_on:
- backend
backend:
condition: service_healthy
environment:
BACKEND_HOST: backend
BACKEND_PORT: 3201
Expand Down
8 changes: 7 additions & 1 deletion integration/docker-compose.ci.canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ services:
image: retrospected/backend:canary
depends_on:
- redis
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3201/healthz"]
interval: 2s
timeout: 5s
retries: 30
environment:
SELF_HOSTED_ADMIN: '[email protected]'
DB_PASSWORD: some-password
Expand All @@ -43,7 +48,8 @@ services:
frontend:
image: retrospected/frontend:canary
depends_on:
- backend
backend:
condition: service_healthy
restart: unless-stopped
logging:
driver: 'json-file'
Expand Down
8 changes: 7 additions & 1 deletion integration/docker-compose.ci.master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ services:
image: retrospected/backend:latest
depends_on:
- redis
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3201/healthz"]
interval: 2s
timeout: 5s
retries: 30
environment:
SELF_HOSTED_ADMIN: '[email protected]'
DB_PASSWORD: some-password
Expand All @@ -43,7 +48,8 @@ services:
frontend:
image: retrospected/frontend:latest
depends_on:
- backend
backend:
condition: service_healthy
restart: unless-stopped
logging:
driver: 'json-file'
Expand Down
70 changes: 70 additions & 0 deletions integration/docker-compose.local.local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
services:
cypress:
image: "cypress/included:12.6.0"
ipc: host
depends_on:
- frontend
environment:
- CYPRESS_baseUrl=http://frontend
- CYPRESS_backend_delay=60000
working_dir: /e2e
volumes:
- ./:/e2e

postgres:
image: postgres:16
hostname: postgres
environment:
POSTGRES_PASSWORD: some-password
POSTGRES_USER: postgres
POSTGRES_DB: retroboard
restart: unless-stopped
logging:
driver: 'json-file'
options:
max-size: '50m'

backend:
image: retro-backend:local
depends_on:
- redis
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3201/healthz"]
interval: 2s
timeout: 5s
retries: 30
environment:
SELF_HOSTED_ADMIN: '[email protected]'
DB_PASSWORD: some-password
SESSION_SECRET: im-a-secret

restart: unless-stopped
logging:
driver: 'json-file'
options:
max-size: '50m'

frontend:
image: retro-frontend:local
depends_on:
backend:
condition: service_healthy
environment:
BACKEND_HOST: backend
BACKEND_PORT: 3201
restart: unless-stopped
logging:
driver: 'json-file'
options:
max-size: '50m'

redis:
image: redis:latest
depends_on:
- postgres
restart: unless-stopped
logging:
driver: 'json-file'
options:
max-size: '50m'

6 changes: 3 additions & 3 deletions integration/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@retrospected/integration",
"version": "5.5.1",
"version": "5.5.2",
"description": "Integrations tests",
"main": "index.js",
"directories": {
Expand All @@ -13,9 +13,9 @@
"author": "Antoine Jaussoin",
"license": "ISC",
"devDependencies": {
"cypress": "^12.17.2"
"cypress": "^13.15.2"
},
"dependencies": {
"typescript": "^5.1.6"
"typescript": "^5.6.3"
}
}
Loading
Loading