Skip to content

Commit 1fc8dc3

Browse files
committed
ci: add a ci with linter support
1 parent eb6869d commit 1fc8dc3

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

.github/workflows/ci.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: CI Workflow
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
pull_request:
9+
branches:
10+
- main
11+
- dev
12+
jobs:
13+
# Job for building the backend (Go)
14+
backend:
15+
name: Build Backend (Go)
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
# Step 1: Checkout the code
20+
- name: Checkout Code
21+
uses: actions/checkout@v3
22+
23+
# Step 2: Set up Go environment
24+
- name: Set up Go
25+
uses: actions/setup-go@v4
26+
with:
27+
go-version: '1.23'
28+
29+
# Step 3: Cache Go modules for faster builds
30+
- name: Cache Go Modules
31+
uses: actions/cache@v3
32+
with:
33+
path: ~/go/pkg/mod
34+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
35+
restore-keys: |
36+
${{ runner.os }}-go-
37+
38+
# Step 4: Run Go Linter
39+
- name: Run GolangCI-Lint Check
40+
uses: golangci/golangci-lint-action@v6
41+
42+
# Step 5: Install Go dependencies
43+
- name: Install Go Dependencies
44+
run: go mod tidy
45+
working-directory: ./server
46+
47+
# Step 6: Build the Go application
48+
- name: Build Go Application
49+
run: go build -o app ./main.go
50+
working-directory: ./server
51+
52+
# Job for building the frontend (React)
53+
frontend:
54+
name: Build Frontend (React)
55+
runs-on: ubuntu-latest
56+
57+
steps:
58+
# Step 1: Checkout the code
59+
- name: Checkout Code
60+
uses: actions/checkout@v3
61+
62+
# Step 2: Set up Node.js environment
63+
- name: Set up Node.js
64+
uses: actions/setup-node@v3
65+
with:
66+
node-version: '18'
67+
68+
# Step 3: Cache Node.js dependencies
69+
- name: Cache Node.js Modules
70+
uses: actions/cache@v3
71+
with:
72+
path: client/node_modules
73+
key: ${{ runner.os }}-node-${{ hashFiles('client/package-lock.json') }}
74+
restore-keys: |
75+
${{ runner.os }}-node-
76+
77+
# Step 4: Install frontend dependencies
78+
- name: Install Dependencies
79+
working-directory: ./client
80+
run: npm install
81+
82+
# Step 5: Build for production
83+
- name: Build Frontend
84+
working-directory: ./client
85+
run: npm run build

0 commit comments

Comments
 (0)