Skip to content

Commit b6dc895

Browse files
authored
ci: Ci patch 1 (#1)
* ci: Create node.js.yml * ci: Update `node.js.yml` to make any ci branch to activate jobs * ci: Fix cache-dependancy-path in yml * fix(api): Update package.json to add placeholder test * ci: test * fix: Update App.js
1 parent 08f9f3d commit b6dc895

4 files changed

Lines changed: 103 additions & 3 deletions

File tree

.github/workflows/node.js.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Full Stack CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- 'ci*'
8+
pull_request:
9+
branches:
10+
- main
11+
- 'ci*'
12+
13+
jobs:
14+
test-api-linux:
15+
name: API Test (Linux)
16+
runs-on: ubuntu-latest
17+
18+
strategy:
19+
matrix:
20+
node-version: [22.x]
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
- run: ls -l api/package-lock.json
25+
- name: Set up Node.js ${{ matrix.node-version }}
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: ${{ matrix.node-version }}
29+
cache: 'npm'
30+
cache-dependency-path: api/package-lock.json
31+
- run: npm ci
32+
working-directory: api
33+
- run: npm test
34+
working-directory: api
35+
36+
test-frontend-linux:
37+
name: Frontend Test (Linux)
38+
runs-on: ubuntu-latest
39+
40+
strategy:
41+
matrix:
42+
node-version: [22.x]
43+
44+
steps:
45+
- uses: actions/checkout@v4
46+
- run: ls -l front-end/package-lock.json
47+
- name: Set up Node.js ${{ matrix.node-version }}
48+
uses: actions/setup-node@v4
49+
with:
50+
node-version: ${{ matrix.node-version }}
51+
cache: 'npm'
52+
cache-dependency-path: front-end/package-lock.json
53+
- run: npm ci
54+
working-directory: front-end
55+
- run: npm test
56+
working-directory: front-end
57+
58+
test-api-windows:
59+
name: API Test (Windows)
60+
runs-on: windows-latest
61+
62+
strategy:
63+
matrix:
64+
node-version: [22.x]
65+
66+
steps:
67+
- uses: actions/checkout@v4
68+
- run: dir api\package-lock.json
69+
- name: Set up Node.js ${{ matrix.node-version }}
70+
uses: actions/setup-node@v4
71+
with:
72+
node-version: ${{ matrix.node-version }}
73+
cache: 'npm'
74+
cache-dependency-path: api/package-lock.json
75+
- run: npm ci
76+
working-directory: api
77+
- run: npm test
78+
working-directory: api
79+
80+
test-frontend-windows:
81+
name: Frontend Test (Windows)
82+
runs-on: windows-latest
83+
84+
strategy:
85+
matrix:
86+
node-version: [22.x]
87+
88+
steps:
89+
- uses: actions/checkout@v4
90+
- run: dir front-end\package-lock.json
91+
- name: Set up Node.js ${{ matrix.node-version }}
92+
uses: actions/setup-node@v4
93+
with:
94+
node-version: ${{ matrix.node-version }}
95+
cache: 'npm'
96+
cache-dependency-path: front-end/package-lock.json
97+
- run: npm ci
98+
working-directory: front-end
99+
- run: npm test
100+
working-directory: front-end

api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.0.0",
44
"main": "index.js",
55
"scripts": {
6-
"test": "echo \"Error: no test specified\" && exit 1",
6+
"test": "echo \"No tests yet\"",
77
"backend": "nodemon server.js "
88
},
99
"nodemonConfig": {

front-end/src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function App() {
1010

1111

1212
return (
13-
<div className="App">
13+
<div className="App" data-testid="testApp">
1414
<Navbar></Navbar>
1515
{/* <div className='sidebar-container'>
1616
<div class="btn-group-horizontal" role="group" aria-label="Vertical radio toggle button group">

front-end/src/App.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import App from './App';
33

44
test('renders learn react link', () => {
55
render(<App />);
6-
const linkElement = screen.getByText(/learn react/i);
6+
const linkElement = screen.getByTestId('testApp');
77
expect(linkElement).toBeInTheDocument();
88
});

0 commit comments

Comments
 (0)