Skip to content

Commit 1ce2930

Browse files
author
pgoetz
committed
Add Forgejo CI/CD
Add Forgejo CI/CD Fix CI Fix CI Fix CI Fix CI Fix CI Fix CI Fix CI Fix CI Fix CI Fix CI
1 parent 6299762 commit 1ce2930

File tree

8 files changed

+1710
-103
lines changed

8 files changed

+1710
-103
lines changed

.forgejo/workflows/pipeline.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
on: [push]
2+
jobs:
3+
ci:
4+
runs-on: docker
5+
container:
6+
image: node:24-alpine
7+
steps:
8+
- uses: actions/checkout@v4
9+
- run: |
10+
npm install
11+
./node_modules/.bin/mocha ./**/*Tests.js
12+
./node_modules/.bin/cucumber-js ./GameController_ATDD
13+
npx eslint .
14+
- uses: actions/upload-artifact@v3
15+
with:
16+
name: unit-test-results
17+
path: testresults_mocha.xml

GameController_Tests/checkIsHitTests.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ describe('checkIsHitTests', function () {
77

88
it('should return true if there is a ship at the shooting position', function () {
99
var ships = gameController.InitializeShips();
10-
counter = 1;
10+
var counter = 1;
1111
ships.forEach(ship => {
1212
for (var i = 1; i <= ship.size; i++) {
13-
column = letters.get(counter);
1413
ship.addPosition(new position(letters.get(counter), i))
1514
}
1615
counter++;
@@ -21,7 +20,7 @@ describe('checkIsHitTests', function () {
2120

2221
it('should return false if there is no ship at the shooting position', function () {
2322
var ships = gameController.InitializeShips();
24-
counter = 1;
23+
var counter = 1;
2524
ships.forEach(ship => {
2625
for (var i = 1; i <= ship.size; i++) {
2726
ship.addPosition(new position(letters.get(counter), i))
@@ -36,16 +35,16 @@ describe('checkIsHitTests', function () {
3635
var ships = gameController.InitializeShips();
3736
assert.throws(
3837
() => {
39-
var actual = gameController.CheckIsHit(ships, undefined);
38+
gameController.CheckIsHit(ships, undefined);
4039
}
4140
)
4241
});
4342

4443
it('should throw an exception if ship is undefined', function () {
4544
assert.throws(
4645
() => {
47-
var actual = gameController.CheckIsHit(undefined, new position(letters.G, 1));
46+
gameController.CheckIsHit(undefined, new position(letters.G, 1));
4847
}
4948
)
5049
});
51-
});
50+
});

TelemetryClient/telemetryClient.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { Worker, isMainThread, parentPort } = require('worker_threads');
1+
const { parentPort } = require('worker_threads');
22

33
const appInsights = require('applicationinsights');
44

@@ -14,4 +14,4 @@ parentPort.on('message', (message) => {
1414
});
1515

1616

17-
17+

ai.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { Worker, isMainThread } = require('worker_threads');
1+
const { Worker } = require('worker_threads');
22
const readline = require('readline-sync');
33

44
let telemetryWorker = new Worker("./TelemetryClient/telemetryClient2.js");

battleship.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { Worker, isMainThread } = require('worker_threads');
1+
const { Worker } = require('worker_threads');
22
const readline = require('readline-sync');
33
const gameController = require("./GameController/gameController.js");
44
const cliColor = require('cli-color');
@@ -71,7 +71,7 @@ class Battleship {
7171
console.log(isHit ? "Yeah ! Nice hit !" : "Miss");
7272

7373
var computerPos = this.GetRandomPosition();
74-
var isHit = gameController.CheckIsHit(this.myFleet, computerPos);
74+
isHit = gameController.CheckIsHit(this.myFleet, computerPos);
7575

7676
telemetryWorker.postMessage({eventName: 'Computer_ShootPosition', properties: {Position: computerPos.toString(), IsHit: isHit}});
7777

@@ -158,4 +158,4 @@ class Battleship {
158158
}
159159
}
160160

161-
module.exports = Battleship;
161+
module.exports = Battleship;

eslint.config.mjs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import js from "@eslint/js";
2+
import globals from "globals";
3+
import { defineConfig } from "eslint/config";
4+
5+
export default defineConfig([
6+
{
7+
files: ["**/*.{js,mjs,cjs}"],
8+
plugins: { js },
9+
extends: ["js/recommended"],
10+
languageOptions: {
11+
globals: {
12+
...globals.node,
13+
...globals.jest
14+
}
15+
},
16+
rules: {
17+
"no-undef": "off",
18+
"no-constant-condition": "off",
19+
}
20+
},
21+
{
22+
files: ["**/*.js"],
23+
languageOptions: {
24+
sourceType: "commonjs"
25+
}
26+
},
27+
]);

0 commit comments

Comments
 (0)