Compare commits

..

45 Commits

Author SHA1 Message Date
tom.coursow dfa0d502d3 .gitea/workflows/services.yml aktualisiert
Test Workflow run in Container / test (push) Successful in 18s
Test Gitea Actions with Service Containers / build (push) Successful in 1m14s
2023-07-27 02:47:20 +02:00
tom.coursow db65c4ab7e .gitea/workflows/services.yml aktualisiert
Test Workflow run in Container / test (push) Successful in 7s
Test Gitea Actions with Service Containers / build (push) Successful in 1m14s
2023-07-27 02:34:21 +02:00
tom.coursow d5ea76f225 data/database.js aktualisiert
Test Workflow run in Container / test (push) Successful in 10s
Test Gitea Actions with Service Containers / build (push) Successful in 1m20s
2023-07-27 02:27:02 +02:00
tom.coursow 52807694aa .gitea/workflows/services.yml aktualisiert
Test Workflow run in Container / test (push) Successful in 8s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-27 02:08:00 +02:00
tom.coursow eaf83b4f67 .gitea/workflows/services.yml aktualisiert
Test Workflow run in Container / test (push) Successful in 7s
Test Gitea Actions with Service Containers / build (push) Failing after 7s
2023-07-27 01:48:02 +02:00
tom.coursow 7ec00540f6 .gitea/workflows/services.yml aktualisiert
Test Workflow run in Container / test (push) Successful in 7s
Test Gitea Actions with Service Containers / build (push) Failing after 27s
2023-07-27 01:44:46 +02:00
tom.coursow 866995f66f .gitea/workflows/services.yml aktualisiert
Test Workflow run in Container / test (push) Successful in 7s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-27 01:43:44 +02:00
tom.coursow 62dc1f9c17 .gitea/workflows/services.yml aktualisiert
Test Workflow run in Container / test (push) Successful in 6s
Test Gitea Actions with Service Containers / build (push) Failing after 6s
2023-07-27 01:40:21 +02:00
tom.coursow 8b2c84f4d7 .gitea/workflows/services.yml aktualisiert
Test Workflow run in Container / test (push) Successful in 7s
Test Gitea Actions with Service Containers / build (push) Failing after 8s
2023-07-27 01:37:43 +02:00
tom.coursow 09c8d20a3b .gitea/workflows/services.yml aktualisiert
Test Workflow run in Container / test (push) Successful in 10s
Test Gitea Actions with Service Containers / build (push) Failing after 12s
2023-07-27 01:31:54 +02:00
tom.coursow a8c9edab78 data/database.js aktualisiert
Test Workflow run in Container / test (push) Successful in 8s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 20:43:23 +02:00
tom.coursow b871a52259 data/database.js aktualisiert
Test Workflow run in Container / test (push) Successful in 8s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 20:40:02 +02:00
tom.coursow 30308552b1 .gitea/workflows/services.yml aktualisiert
Test Workflow run in Container / test (push) Successful in 8s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 20:32:29 +02:00
tom.coursow 10b73ce74e .gitea/workflows/services.yml aktualisiert
Test Workflow run in Container / test (push) Successful in 8s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 20:30:31 +02:00
tom.coursow 7af6e3bd99 .gitea/workflows/services.yml aktualisiert
Test Gitea Actions with Service Containers / build (push) Has been cancelled
Test Workflow run in Container / test (push) Successful in 8s
2023-07-17 20:29:30 +02:00
tom.coursow 698a01cfe9 .gitea/workflows/services.yml aktualisiert
Test Workflow run in Container / test (push) Successful in 8s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 20:28:14 +02:00
tom.coursow 66e2fda0ae README.md aktualisiert
Test Workflow run in Container / test (push) Successful in 9s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 20:23:21 +02:00
tom.coursow b18fe2c207 README.md aktualisiert 2023-07-17 20:22:44 +02:00
tom.coursow 09b3ee9b10 Update .gitea/workflows/services.yml
Test Workflow run in Container / test (push) Successful in 8s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 20:16:55 +02:00
tom.coursow ad94a6ab07 Update .gitea/workflows/services.yml
Test Workflow run in Container / test (push) Successful in 9s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 20:14:57 +02:00
tom.coursow 3e59f023a1 Update .gitea/workflows/services.yml
Test Workflow run in Container / test (push) Successful in 8s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 20:03:17 +02:00
tom.coursow 2d199bb143 Update .gitea/workflows/services.yml
Test Workflow run in Container / test (push) Successful in 9s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 19:59:34 +02:00
tom.coursow 49c211d372 Update .gitea/workflows/services.yml
Test Workflow run in Container / test (push) Successful in 8s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 19:47:40 +02:00
tom.coursow 542670be57 Update .gitea/workflows/services.yml
Test Workflow run in Container / test (push) Successful in 9s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 19:43:08 +02:00
tom.coursow f16a32a0ae Update .gitea/workflows/services.yml
Test Workflow run in Container / test (push) Successful in 12s
Test Gitea Actions with Service Containers / build (push) Failing after 12m22s
2023-07-17 18:50:01 +02:00
tom.coursow ecb3eebd1b Update .gitea/workflows/services.yml
Test Workflow run in Container / test (push) Successful in 9s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 18:19:06 +02:00
tom.coursow d034e49b02 Update .gitea/workflows/services.yml
Test Workflow run in Container / test (push) Successful in 8s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 18:14:01 +02:00
tom.coursow cee0cea3e7 Update README.md
Test Workflow run in Container / test (push) Successful in 8s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 18:01:19 +02:00
tom.coursow 31d9e194c9 Update data/database.js
Test Workflow run in Container / test (push) Successful in 9s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 17:54:53 +02:00
tom.coursow 26d00748a1 Update .gitea/workflows/services.yml
Test Workflow run in Container / test (push) Successful in 9s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 17:44:06 +02:00
tom.coursow ea0a82b3ad Update .gitea/workflows/services.yml
Test Workflow run in Container / test (push) Successful in 9s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 17:37:09 +02:00
tom.coursow 55fe3cbe29 Update README.md
Test Workflow run in Container / test (push) Successful in 8s
Test Gitea Actions with Service Containers / build (push) Failing after 0s
2023-07-17 17:36:25 +02:00
tom.coursow 7f5b9df217 Update .gitea/workflows/services.yml
Test Workflow run in Container / test (push) Has been cancelled
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 17:28:13 +02:00
tom.coursow 81c4488efa Update .gitea/workflows/services.yml
Test Workflow run in Container / test (push) Successful in 10s
Test Gitea Actions with Service Containers / build (push) Failing after 12m31s
2023-07-17 17:09:59 +02:00
tom.coursow 973e9268f8 Update .gitea/workflows/services.yml
Test Workflow run in Container / test (push) Successful in 7s
Test Gitea Actions with Service Containers / build (push) Failing after 12s
2023-07-17 17:08:17 +02:00
tom.coursow a376edc368 Update .gitea/workflows/services.yml
Test Workflow run in Container / test (push) Successful in 7s
Test Gitea Actions with Service Containers / build (push) Failing after 8s
2023-07-17 17:06:20 +02:00
tom.coursow b77264eae6 Update .gitea/workflows/services.yml
Test Gitea Actions with Service Containers / build (push) Failing after 10s
Test Workflow run in Container / test (push) Successful in 9s
2023-07-17 17:03:51 +02:00
tom.coursow 817b3be213 Update .gitea/workflows/services.yml
Test Workflow run in Container / test (push) Successful in 9s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 17:00:00 +02:00
tom.coursow a02ff2f975 Update .gitea/workflows/services.yml
Test Workflow run in Container / test (push) Successful in 7s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 16:56:32 +02:00
tom.coursow 5af6fee1eb Update data/database.js
Test Workflow run in Container / test (push) Successful in 8s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 16:53:45 +02:00
tom.coursow fac4aa465f Update .gitea/workflows/services.yml
Test Workflow run in Container / test (push) Successful in 8s
Test Gitea Actions with Service Containers / build (push) Has been cancelled
2023-07-17 16:47:58 +02:00
tom.coursow e51521680e Update .gitea/workflows/services.yml
Test Gitea Actions with Service Containers / build (push) Has been cancelled
Test Workflow run in Container / test (push) Successful in 7s
2023-07-17 16:43:29 +02:00
tom.coursow c68b604daa Update .gitea/workflows/services.yml
Test Workflow run in Container / test (push) Successful in 10s
Test Gitea Actions with Service Containers / build (push) Failing after 2s
2023-07-17 16:41:40 +02:00
tom.coursow 33c7e9df18 removed weird file
Test Workflow run in Container / test (push) Successful in 11s
2023-07-17 16:40:42 +02:00
tom.coursow 5c635fd321 Added test project requiring mongodb and added new workflow to test Gitea Actions - Service Containers 2023-07-17 16:39:34 +02:00
11 changed files with 1657 additions and 0 deletions
Vendored
BIN
View File
Binary file not shown.
+43
View File
@@ -0,0 +1,43 @@
name: Test Gitea Actions with Service Containers
on: push
env:
# Global Env Variables readable in all jobs of this workflow
MONGODB_CLUSTER_ADDRESS: mongodb # The network alias name of the mongodb docker service container
# Env Variables which the Example JS App will access
MONGODB_USERNAME: root
MONGODB_PASSWORD: supersecretpassword
MONGODB_DB_NAME: actionsenvironment
PORT: 8080
jobs:
build:
# Job will execute the Steps inside a 'node:latest' docker container
container:
image: node:latest
runs-on: ubuntu-latest
services:
# Before running the Steps of this job...
# The runner will spawm a second container 'mongodb' using the mongo:latest image with some db settings
# The node container and the mongodb container will be in a new temporary docker bridge network
mongodb:
image: mongo:latest
# Docker related container env Variables for the mongo image (JS App will not have these variables)
env:
MONGO_INITDB_DATABASE: actionsenvironment
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: supersecretpassword
steps:
- name: Install NodeJS
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Get Code
uses: actions/checkout@v3
- name: Install dependencies
run: npm ci
- name: Run server
run: npm start & npx wait-on http://127.0.0.1:$PORT
- name: Run tests
run: npm test
+4
View File
@@ -0,0 +1,4 @@
node_modules/
/test-results/
/playwright-report/
/playwright/.cache/
+17
View File
@@ -0,0 +1,17 @@
FROM node:16
ENV MONGODB_CONNECTION_PROTOCOL mongodb+srv
ENV MONGODB_DB_NAME gha-demo1
ENV MONGODB_CLUSTER_ADDRESS cluster0.ntrwp.mongodb.net
ENV MONGODB_USERNAME maximilian
ENV MONGODB_PASSWORD eI3R3UfNlJgWJe17
WORKDIR /app
COPY package*.json .
RUN npm install
COPY . .
CMD ["npm", "start"]
+12
View File
@@ -0,0 +1,12 @@
import bodyParser from 'body-parser';
import express from 'express';
import eventRoutes from './routes/events.js';
const app = express();
app.use(bodyParser.json());
app.use(eventRoutes);
app.listen(process.env.PORT);
+27
View File
@@ -0,0 +1,27 @@
import { MongoClient } from 'mongodb';
const clusterAddress = process.env.MONGODB_CLUSTER_ADDRESS;
const dbUser = process.env.MONGODB_USERNAME;
const dbPassword = process.env.MONGODB_PASSWORD;
const dbName = process.env.MONGODB_DB_NAME;
const uri = `mongodb://${dbUser}:${dbPassword}@${clusterAddress}/?retryWrites=true&w=majority`;
const client = new MongoClient(uri);
console.log('Trying to connect to db: ' + uri);
try {
await client.connect();
await client.db(dbName).command({ ping: 1 });
console.log('Connected successfully to server');
} catch (error) {
console.log(error)
console.log('Connection failed.');
await client.close();
console.log('Connection closed.');
process.exit(1);
}
const database = client.db(dbName);
export default database;
+1453
View File
File diff suppressed because it is too large Load Diff
+23
View File
@@ -0,0 +1,23 @@
{
"name": "backend",
"version": "1.0.0",
"description": "",
"type": "module",
"main": "index.js",
"scripts": {
"start": "node app.js",
"test": "npx playwright test"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.20.0",
"express": "^4.18.1",
"mongodb": "^4.9.1"
},
"devDependencies": {
"@playwright/test": "^1.25.1",
"playwright": "^1.25.1"
}
}
+32
View File
@@ -0,0 +1,32 @@
/**
* @see https://playwright.dev/docs/test-configuration
* @type {import('@playwright/test').PlaywrightTestConfig}
*/
const config = {
testDir: './tests',
/* Maximum time one test can run for. */
timeout: 30 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 5000,
},
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
baseURL: `http://127.0.0.1:${process.env.PORT}`,
},
};
export default config;
+21
View File
@@ -0,0 +1,21 @@
import { Router } from 'express';
import db from '../data/database.js';
const router = Router();
router.get('/', async (req, res) => {
const allEvents = await db.collection('events').find().toArray();
res.json({ events: allEvents });
});
router.post('/', async (req, res) => {
const eventData = req.body;
const result = await db.collection('events').insertOne({...eventData});
res.status(201).json({
message: 'Event created.',
event: { ...eventData, id: result.insertedId },
});
});
export default router;
+25
View File
@@ -0,0 +1,25 @@
// @ts-check
import { test, expect } from '@playwright/test';
test('event creation', async ({ request }) => {
const testTitle = 'Test event';
const response = await request.post('/', {
data: {
title: testTitle,
},
});
expect(response.ok()).toBeTruthy();
const resDataRaw = await response.body();
const resData = JSON.parse(resDataRaw.toString());
expect(resData).toHaveProperty('event.id');
expect(resData.event.title).toBe(testTitle);
});
test('getting events', async ({ request }) => {
const response = await request.get('/');
expect(response.ok()).toBeTruthy();
const resDataRaw = await response.body();
const resData = JSON.parse(resDataRaw.toString());
expect(resData).toHaveProperty('events');
expect(resData.events.length).toBeGreaterThan(0);
});