Skip to content

Commit

Permalink
ci: test using containers, unify build script (#97)
Browse files Browse the repository at this point in the history
* ci: test using containers, unify build script

* ci: bump github actions action versions
  • Loading branch information
alubbock authored Oct 10, 2024
1 parent 58a5839 commit 55fa77d
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 144 deletions.
44 changes: 0 additions & 44 deletions .github/workflows/backend.yml

This file was deleted.

62 changes: 62 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build, test and push backend container

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
component: [backend, frontend]

steps:
- name: Checkout Source
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Quay.io
uses: docker/login-action@v3
with:
registry: quay.io
username: rosalindfranklininstitute+github_antigenapp
password: ${{ secrets.QUAYIO_TOKEN }}

- name: Build dev image
uses: docker/build-push-action@v6
with:
context: ${{ matrix.component }}
target: dev
platforms: linux/amd64
load: true
tags: antigen-app-dev-${{ matrix.component }}:latest

- name: Run backend tests
if: ${{ matrix.component == 'backend' }}
run: |
docker run --rm -e DJANGO_CI=true antigen-app-dev-backend:latest pipenv run tests
- name: Run frontend tests
if: ${{ matrix.component == 'frontend' }}
run: |
docker run --rm -e CI=true antigen-app-dev-frontend:latest npm test
docker run --rm antigen-app-dev-frontend:latest npx prettier --check .
- name: Build and push prod image
uses: docker/build-push-action@v6
with:
context: ${{ matrix.component }}
target: prod
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: quay.io/rosalindfranklininstitute/antigen-app-${{ matrix.component }}:latest
45 changes: 0 additions & 45 deletions .github/workflows/containers.yml

This file was deleted.

49 changes: 0 additions & 49 deletions .github/workflows/frontend.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ To run the backend (Python+Django) test suite:

To run the test suite:

docker compose exec app npm test
docker compose exec -e CI=true app npm test
2 changes: 2 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ FROM builder AS dev

ENV PATH="$PATH:/root/.local/bin:/usr/src/.venv/bin"

RUN pipenv sync --dev

CMD ["pipenv", "run", "python", "manage.py", "runserver", "0.0.0.0:8080"]
11 changes: 6 additions & 5 deletions frontend/src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { render, screen } from "@testing-library/react";
import React from "react";
import App from "./App";
import { createRoot } from "react-dom/client";

test("renders learn react link", () => {
render(<App />);
const linkElement = screen.getByText(/Named Nanobodies/);
expect(linkElement).toBeInTheDocument();
it("renders without crashing", () => {
const container = document.createElement("div");
const root = createRoot(container);
root.render(<App />);
});

0 comments on commit 55fa77d

Please sign in to comment.