Skip to content

Commit 239b6c3

Browse files
committed
add github workflows and fix initial tests
1 parent e60ff88 commit 239b6c3

File tree

5 files changed

+85
-6
lines changed

5 files changed

+85
-6
lines changed

.github/workflows/deploy.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build and push to gh-pages
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Node.js CI"]
6+
types: [completed]
7+
branches:
8+
- main
9+
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event.workflow_dispatch }}
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Configure git
22+
run: |
23+
git config --global user.name "github-actions"
24+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
25+
26+
- name: Use Node.js 18.x
27+
uses: actions/setup-node@v3
28+
with:
29+
node-version: 18.x
30+
cache: "npm"
31+
32+
- name: Install dependencies
33+
run: npm install
34+
35+
- name: Deploy to gh pages
36+
run: |
37+
npx ng deploy \
38+
--repo=https://${{ secrets.GH_TOKEN }}@github.com/chrispyles/amaze.git \
39+
--base-href="/amaze/"
40+
--silent
41+
env:
42+
CI: true

.github/workflows/run-tests.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
3+
4+
name: Node.js CI
5+
6+
on:
7+
push:
8+
branches: ["main"]
9+
pull_request:
10+
branches: ["main"]
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Use Node.js 18.x
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: 18.x
23+
cache: "npm"
24+
25+
- name: CI
26+
run: npm ci
27+
28+
- name: Build
29+
run: npm run build --if-present
30+
31+
- name: Run tests
32+
run: npm run test:ci

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"build": "ng build",
88
"watch": "ng build --watch --configuration development",
99
"test": "ng test",
10+
"test:ci": "ng test --browsers=ChromeHeadless --code-coverage --source-map=false --watch=false",
1011
"format": "prettier -w src"
1112
},
1213
"private": true,

src/app/maze/maze.component.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
22

33
import { MazeComponent } from './maze.component';
4+
import { Chooser, Maze } from '../../lib';
45

56
describe('MazeComponent', () => {
67
let component: MazeComponent;
78
let fixture: ComponentFixture<MazeComponent>;
89

910
beforeEach(async () => {
1011
await TestBed.configureTestingModule({
11-
imports: [MazeComponent]
12-
})
13-
.compileComponents();
12+
imports: [MazeComponent],
13+
}).compileComponents();
1414

1515
fixture = TestBed.createComponent(MazeComponent);
1616
component = fixture.componentInstance;
17+
const componentRef = fixture.componentRef;
18+
componentRef.setInput('maze', new Maze(20, new Chooser(42)));
1719
fixture.detectChanges();
1820
});
1921

src/app/node/node.component.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
22

33
import { NodeComponent } from './node.component';
4+
import { Chooser, Node } from '../../lib';
45

56
describe('NodeComponent', () => {
67
let component: NodeComponent;
78
let fixture: ComponentFixture<NodeComponent>;
89

910
beforeEach(async () => {
1011
await TestBed.configureTestingModule({
11-
imports: [NodeComponent]
12-
})
13-
.compileComponents();
12+
imports: [NodeComponent],
13+
}).compileComponents();
1414

1515
fixture = TestBed.createComponent(NodeComponent);
1616
component = fixture.componentInstance;
17+
const componentRef = fixture.componentRef;
18+
componentRef.setInput('node', new Node(0, 0, 20, new Chooser(42)));
1719
fixture.detectChanges();
1820
});
1921

0 commit comments

Comments
 (0)