Skip to content

GitHub Actions

Francois edited this page Dec 19, 2025 · 4 revisions

Presentation: GitHub Action is a continuous integration and continuous delivery platform to automate build, tests and deployment.

In the context of Transcendence project, it is especially helpful for:

  • code quality: automation of linters, compilation and tests on pushed and PR to main
  • portability: allows testing in a clean Ubuntu environment

Alternatives : Jenkins

Setup

Prerequisites

Our project should define

  • Make rules

  • Scripts (in package.json and to a certain extent separate files).

  "build": "tsc",
  "lint": "eslint .",
  "test": "vitest",
  "postinstall": "prisma generate",

Configuration

At the project root, in a .yml file

.github/
โ””โ”€โ”€ workflows/
    โ””โ”€โ”€ ci.yml

Matrixes

Can execute in parallel a job on different configuration (ex: different Node versions or OS)

CLI

Use cases

Continuous integration workflow

name: CI Pipeline

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build-and-test:
    name: Build & Test
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [24.x]

    steps:
      # Check out the repository code = clone it
      - name: Checkout Code
        uses: actions/checkout@v4

      # Setup Node.js environment
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v4
        with:
          node-version: ${{ matrix.node-version }}
          cache: 'npm' # Automatically caches node_modules

      # Install Dependencies
      # This will also trigger 'npx prisma generate' if defined in postinstall
      # Using ci = clean install from the package-lock.json rather than i
      - name: Install Dependencies
        run: npm ci

      # Linting
      - name: Run Linter
        run: npm run lint

      # Build Project
      - name: Build
        run: npm run build

      # Run Tests
      # Ensure required env vars is set for tests (dummy value for schema validation)
      - name: Run Tests
        env:
          UM_DB_URL: "file:./test.db" 
        run: npm test

Deployment workflow

No attempt yet

Do's & Don'ts

โœ… Do โŒ Don't
Cache dependencies -
Use GitHub Secrets Commit .env files
Always include npx prisma generate before building or testing -
Separate jobs : split linting, building, testing -
Pin action versions on a SHA Not pin or pin on a tag such as @v1

Tip

To get a tag SHA gh api repos/actions/checkout/commits/v4 --jq .sha

Resources

Type Ressource Notes
๐Ÿ“„ Official Docs -
๐Ÿ“„ Starter workflow -
๐Ÿ“ฆ Official CLI -
๐Ÿ“ฆ ACT Test workflows locally
๐Ÿ’ก Good intro -
๐Ÿ’ก Sรฉcuritรฉ GHA -

Legend: ๐Ÿ“„ Doc, ๐Ÿ“˜ Book, ๐ŸŽฅ Video, ๐Ÿ’ป GitHub, ๐Ÿ“ฆ Package, ๐Ÿ’ก Blog

๐Ÿ—๏ธ Architecture

๐ŸŒ Web Technologies

Backend

Frontend

๐Ÿ”ง Core Technologies

๐Ÿ” Security

โ›“๏ธ Blockchain

๐Ÿ› ๏ธ Dev Tools & Quality


๐Ÿ“ Page model

Clone this wiki locally