|
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 |
| 1 | +# .github/workflows/ci.yml |
3 | 2 |
|
4 | | -name: Node.js CI |
| 3 | +# Name of the workflow, displayed in the "Actions" tab on GitHub. |
| 4 | +name: Frontend CI |
5 | 5 |
|
| 6 | +# --- Triggers --- |
| 7 | +# Defines when the workflow will run. |
6 | 8 | on: |
| 9 | + # Run on every push to any branch. |
7 | 10 | push: |
8 | | - branches: [ "main" ] |
| 11 | + branches: [ "**" ] |
| 12 | + |
| 13 | + # Also run on pull requests targeting the 'main' branch. |
9 | 14 | pull_request: |
10 | 15 | branches: [ "main" ] |
11 | 16 |
|
12 | | -jobs: |
13 | | - build: |
| 17 | + # Allows manual triggering from the GitHub Actions UI. |
| 18 | + workflow_dispatch: |
14 | 19 |
|
| 20 | +# --- Jobs --- |
| 21 | +# A workflow is made up of one or more jobs. |
| 22 | +jobs: |
| 23 | + # The single job in this workflow is named "build-and-test". |
| 24 | + build-and-test: |
| 25 | + # The type of virtual machine to run the job on. |
15 | 26 | runs-on: ubuntu-latest |
16 | 27 |
|
17 | | - strategy: |
18 | | - matrix: |
19 | | - node-version: [18.x, 20.x, 22.x] |
20 | | - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ |
21 | | - |
| 28 | + # A job is a sequence of steps. |
22 | 29 | steps: |
23 | | - - uses: actions/checkout@v4 |
24 | | - - name: Use Node.js ${{ matrix.node-version }} |
25 | | - uses: actions/setup-node@v4 |
26 | | - with: |
27 | | - node-version: ${{ matrix.node-version }} |
28 | | - cache: 'npm' |
29 | | - - run: npm ci |
30 | | - - run: npm run build --if-present |
31 | | - - run: npm test |
| 30 | + # --- 1. Checkout Code --- |
| 31 | + # Checks out your repository's code so the workflow can access it. |
| 32 | + - name: Checkout repository |
| 33 | + uses: actions/checkout@v4 |
| 34 | + |
| 35 | + # --- 2. Setup Node.js Environment --- |
| 36 | + # Installs a specific version of Node.js on the runner. |
| 37 | + - name: Setup Node.js |
| 38 | + uses: actions/setup-node@v4 |
| 39 | + with: |
| 40 | + node-version: '22' # Using a specific major version is recommended. |
| 41 | + # Automatically cache npm dependencies for faster builds. |
| 42 | + cache: 'npm' |
| 43 | + |
| 44 | + # --- 3. Install Dependencies --- |
| 45 | + # Runs "npm install" to install all packages from package.json and package-lock.json. |
| 46 | + - name: Install dependencies |
| 47 | + run: npm ci # 'npm ci' is often faster and more reliable for CI environments than 'npm install'. |
| 48 | + |
| 49 | + # --- 4. Run Linter --- |
| 50 | + # Executes the "lint" script defined in your package.json to check for code quality. |
| 51 | + - name: Run linter |
| 52 | + run: npm run lint |
| 53 | + |
| 54 | + # --- 5. Run Tests --- |
| 55 | + # Executes the "test" script defined in your package.json. |
| 56 | + # This runs your Vitest suite and will fail the workflow if any tests fail. |
| 57 | + - name: Run tests |
| 58 | + run: npm run test |
| 59 | + |
| 60 | + # --- 6. Build for Production --- |
| 61 | + # Executes the "build" script. This is a crucial step to ensure that the |
| 62 | + # application is actually buildable and ready for deployment. |
| 63 | + - name: Build application |
| 64 | + run: npm run build |
0 commit comments