-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 772e1ed
Showing
61 changed files
with
11,259 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Deploy to production | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
test: | ||
uses: ./.github/workflows/test.yaml | ||
|
||
build-and-push: | ||
runs-on: ubuntu-latest | ||
needs: test | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Build image | ||
id: build-image | ||
uses: redhat-actions/buildah-build@v2 | ||
with: | ||
image: openid-mongo-example | ||
tags: production ${{ github.sha }} | ||
containerfiles: | | ||
./Containerfile | ||
- name: Push to quay.io | ||
uses: redhat-actions/push-to-registry@v2 | ||
with: | ||
image: ${{ steps.build-image.outputs.image }} | ||
tags: ${{ steps.build-image.outputs.tags }} | ||
registry: quay.io/toska | ||
username: toska+github | ||
password: ${{ secrets.QUAY_IO_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Deploy to staging | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
uses: ./.github/workflows/test.yaml | ||
|
||
build-and-push: | ||
runs-on: ubuntu-latest | ||
needs: test | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Build image | ||
id: build-image | ||
uses: redhat-actions/buildah-build@v2 | ||
with: | ||
image: openid-mongo-example | ||
tags: staging ${{ github.sha }} | ||
containerfiles: | | ||
./Containerfile | ||
build-args: | | ||
BASE_PATH=/example | ||
STAGING=true | ||
- name: Push to quay.io | ||
uses: redhat-actions/push-to-registry@v2 | ||
with: | ||
image: ${{ steps.build-image.outputs.image }} | ||
tags: ${{ steps.build-image.outputs.tags }} | ||
registry: quay.io/toska | ||
username: toska+github | ||
password: ${{ secrets.QUAY_IO_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: E2E Tests | ||
|
||
on: [workflow_call] | ||
|
||
jobs: | ||
eslint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Build project for eslint | ||
run: npm install | ||
|
||
- name: Run eslint | ||
run: npm run lint | ||
|
||
cypress: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Prepare test data and start the application | ||
run: docker compose -f compose.ci.yaml up -d | ||
|
||
- name: Cypress run | ||
uses: cypress-io/github-action@v5 | ||
with: | ||
browser: chrome | ||
install-command: npm i | ||
|
||
- name: Upload video | ||
uses: actions/upload-artifact@v3 | ||
if: failure() | ||
with: | ||
path: /home/runner/work/openid-mongo-example/openid-mongo-example/cypress/videos/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
debug.log | ||
node_modules | ||
dist | ||
.vscode | ||
.env | ||
videos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM registry.access.redhat.com/ubi9/nodejs-18-minimal | ||
|
||
ENV TZ="Europe/Helsinki" | ||
|
||
WORKDIR /opt/app-root/src | ||
|
||
ARG BASE_PATH | ||
ENV BASE_PATH=$BASE_PATH | ||
|
||
ARG STAGING | ||
ENV STAGING=$STAGING | ||
|
||
ARG E2E | ||
ENV E2E=$E2E | ||
|
||
COPY package* ./ | ||
RUN npm ci --omit-dev --ignore-scripts | ||
COPY . . | ||
|
||
RUN npm run build | ||
|
||
EXPOSE 8000 | ||
|
||
CMD ["npm", "run", "prod"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# OpenID Mongo Example | ||
|
||
Example TypeScript setup for Software Engineering projects using OpenID Connect and MongoDB | ||
|
||
## Development | ||
|
||
- Install npm, docker and docker compose | ||
- Clone the repository | ||
- Run `npm i` and `npm start` to setup and start the development environment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
services: | ||
app: | ||
build: | ||
context: ./ | ||
dockerfile: Containerfile | ||
args: | ||
- E2E=true | ||
image: test | ||
environment: | ||
- DATABASE_URL=mongodb://root:root@db/admin | ||
ports: | ||
- 8000:8000 | ||
container_name: test | ||
|
||
db: | ||
image: docker.io/mongo:7.0.0 | ||
environment: | ||
- MONGO_INITDB_ROOT_USERNAME=root | ||
- MONGO_INITDB_ROOT_PASSWORD=root | ||
ports: | ||
- 27017:27017 | ||
container_name: test_db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
services: | ||
app: | ||
build: | ||
context: ./ | ||
dockerfile: dev.Containerfile | ||
image: dev | ||
environment: | ||
- DATABASE_URL=mongodb://root:root@db/admin | ||
volumes: | ||
- ./:/opt/app-root/src | ||
ports: | ||
- 3000:3000 | ||
- 8000:8000 | ||
container_name: dev | ||
|
||
db: | ||
image: docker.io/mongo:7.0.0 | ||
environment: | ||
- MONGO_INITDB_ROOT_USERNAME=root | ||
- MONGO_INITDB_ROOT_PASSWORD=root | ||
ports: | ||
- 27017:27017 | ||
volumes: | ||
- mongo_data:/data/db | ||
container_name: dev_db | ||
|
||
volumes: | ||
mongo_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineConfig } from 'cypress' | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
setupNodeEvents(_on, _config) { | ||
// implement node event listeners here | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { baseUrl } from '../support/e2e' | ||
|
||
describe('Example', () => { | ||
beforeEach(() => { | ||
cy.visit(baseUrl) | ||
}) | ||
|
||
it('loads the main page', () => { | ||
cy.contains('Esimerkkisovellus') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "[email protected]", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/// <reference types="cypress" /> | ||
// *********************************************** | ||
// This example commands.ts shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add('login', (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) | ||
// | ||
// declare global { | ||
// namespace Cypress { | ||
// interface Chainable { | ||
// login(email: string, password: string): Chainable<void> | ||
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element> | ||
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element> | ||
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element> | ||
// } | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// *********************************************************** | ||
// This example support/e2e.ts is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' | ||
|
||
export const baseUrl = 'localhost:8000' | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM docker.io/node:18-alpine | ||
|
||
ENV TZ="Europe/Helsinki" | ||
|
||
WORKDIR /opt/app-root/src | ||
|
||
COPY package* ./ | ||
RUN npm i | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["npm", "run", "dev"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/png" href="/hy_favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>OpenID Mongo Example</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/client/index.tsx"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.