Makers of a sustainable future

Råd og best practices med github

*

Alexander Vassbotn Røyne-Helgesen

Principal Engineer

Hva gir github oss?

Tips og triks

Actions

name: Checks
on:
  pull_request:
    branches: [ "main" ]
    types: [opened, synchronize]
jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Setup Node.js environment
        uses: actions/setup-node@v4
        with:
          node-version: '>=20.11.1'
      - name: Install dependencies
        run:  npm i
      - name: Build
        run: npm run build
      - name: Test
        run: npm run test-ci
      - name: Upload coverage reports to Codecov
        uses: codecov/codecov-action@v4.0.1
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          slug: phun-ky/speccer
  notify:
    name: Notify failed check
    needs: check
    if: failure()
    runs-on: ubuntu-latest
    steps:
      - uses: jayqi/failed-build-issue-action@v1.2
        with:
          github-token: ${{ secrets.GH_TOKEN }}


Auto labeler

name: "Pull Request Labeler"
on:
- pull_request_target

jobs:
  labeler:
    permissions:
      contents: read
      pull-requests: write
    runs-on: ubuntu-latest
    steps:
    - id: label-the-PR
      uses: actions/labeler@v5
      with:
        sync-labels: true
'section: workflows':
  - any:
      - changed-files:
          - any-glob-to-any-file:
              - .github/workflows/**
'section: repo':
  - any:
      - changed-files:
          - any-glob-to-any-file:
              - '*'
'experience: developer':
  - any:
      - changed-files:
          - any-glob-to-any-file:
              - '.editorconfig'
              - '.eslintignore'
              - '.eslintrc.json'
              - '.eslintrc.js'
              - '.gitignore'
              - '.release-it.json'
              - '.renovate.json'
              - '.npmrc'
              - '.prettierrc'
              - 'tslint.json'
'context: github':
  - any:
      - changed-files:
          - any-glob-to-any-file:
              - .github/**
'context: docker':
  - any:
      - changed-files:
          - any-glob-to-any-file:
              - Dockerfile
'context: npm':
  - any:
      - changed-files:
          - any-glob-to-any-file:
              - '.npmrc'
'context: rollup':
  - any:
      - changed-files:
          - any-glob-to-any-file:
              - 'rollup.config.js'
              - 'rollup.config.mjs'
              - 'rollup.*.config.js'
              - 'rollup.*.config.mjs'
'mindless: docs':
  - any:
      - head-branch: ['^docs', 'docs']
      - changed-files:
          - any-glob-to-any-file:
              - '**/*.md'
'mindless: dependencies':
  - any:
      - changed-files:
          - any-glob-to-any-file:
              - 'package-lock.json'
              - 'yarn.lock'

# Add '✨ feature' label to any PR where the head branch name starts with `feat` or has a `feat` section in the name
'✨ feature':
  - head-branch: ['^feat', 'feat']
'problems: bug':
  - head-branch: ['^fix', 'fix']
'mindless: chore':
  - head-branch: ['^chore', 'chore']
'improvements: enhancement':
  - head-branch: ['^improvements', 'improvements']

# Add 'release' label to any PR that is opened against the `main` branch
release:
  - base-branch: 'main'
$ gh label clone entur/products-models --repo entur/vite-plugin-assets-json

Depandabot

version: 2
updates:
  - package-ecosystem: 'npm'
    directory: '/'
    schedule:
      interval: 'weekly'
    commit-message:
      prefix: 'chore: 🤖 '

Auto assign

name: Auto Assign
on:
  issues:
    types: [opened]
  pull_request:
    types: [opened]
jobs:
  run:
    runs-on: ubuntu-latest
    permissions:
      issues: write
      pull-requests: write
    steps:
    - name: 'Auto-assign issue'
      uses: pozil/auto-assign-issue@v1
      with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          assignees: phun-ky
          numOfAssignee: 1

Best practices

Versjonering

  • Forbedret kommunikasjon med release notes/changelog
  • Enklere referanser
  • Forutsigbarhet og konsistens
  • Release feature transparency
  • Integrasjon med verktøy som Sentry
  • Langsiktig vedlikehold og samarbeid
  • Bedre kontroll over utgivelser
  • Standard praksis i bransjen
  • Rollback og patch management

SemVer

Semantic versioning (semver) consists of three numbers: MAJOR, MINOR, and PATCH. Each number is incremented in different circumstances:

  • the MAJOR version when we make incompatible API changes (read: breaking changes),
  • the MINOR version when we add functionality in a backward-compatible manner, and
  • the PATCH version when we make backward-compatible bug fixes.


Using SemVer helps a great deal for developers, and non-developers to understand what has changed, since the changed number in the version reflects what the actual change consists of.

Commitizen

$ git log --pretty=format:'%h %s'.
3332279 style: 💄 Lint.
60f0ec8 fix: 🐛 Fix sticky header issues.
9f5fdcd feat: 🎸 Add read time.
55bf3ad feat: 🎸 Add copy code button and language string to code blocks.
813df4a refactor: 💡 Some adjustments.
79549ab refactor: 💡 Adjust code blocks.
6876cec fix: 🐛 Add label attribute to heading link.
8bf68c6 refactor: 💡 Comment out copy / language feat for prism.
9f97ebf feat: 🎸 Make header sticky in desktop mode.
95ceac0 style: 💄 Tune lint rules for markdown.
d7c3a13 feat: 🎸 Add `print.css`.
$ npm run commit

> phun-ky.github.io@1.0.0 commit
> git cz

? Select the type of change that you're committing: (Use arrow keys or type to search)
❯ 💍  test:       Adding missing tests
  🎸  feat:       A new feature
  🐛  fix:         A bug fix
  🤖  chore:      Build process or auxiliary tool changes
  ✏️  docs:       Documentation only changes
  💡  refactor:   A code change that neither fixes a bug or adds a feature
  💄  style:      Markup, white-space, formatting, missing semi-colons...
(Move up and down to reveal more choices)
$ git log
commit 8f82e8189e614332b6c80d2ab8291aa59325b130 (HEAD -> main)
Author: Alexander Vassbotn Røyne-Helgesen <alexander+github.com@phun-ky.net>
Date:   Fri Jan 5 15:11:19 2024 +0100

    style: 💄 lint `src/styles/index.styl`

    For funsies

    ✅ Closes: #123

Release It

{
  "git": {
    "commitMessage": "chore: 🤖 release v${version}"
  },
  "github": {
    "release": true,
    "tokenRef": "GH_TOKEN"
  },
  "npm": {
    "publish": true,
    "skipChecks": true
  },
  "hooks": {
    "after:bump": "npm run build && npm run docs:gen",
    "after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
  },
  "plugins": {
    "@release-it/conventional-changelog": {
      "header": "# Changelog",
      "preset": {
        "name": "conventionalcommits",
        "types": [
          {
            "type": "chore",
            "section": "Tasks"
          },
          {
            "type": "docs",
            "section": "Documentation"
          },
          {
            "type": "feat",
            "section": "Feature"
          },
          {
            "type": "fix",
            "section": "Bug"
          },
          {
            "type": "perf",
            "section": "Performance change"
          },
          {
            "type": "refactor",
            "section": "Refactoring"
          },
          {
            "type": "release",
            "section": "Create a release commit",
            "hidden": true
          },
          {
            "type": "style",
            "section": "Markup, white-space, formatting, missing semi-colons...",
            "hidden": true
          },
          {
            "type": "test",
            "section": "Adding missing tests",
            "hidden": true
          }
        ]
      },
      "infile": "CHANGELOG.md"
    }
  }
}

Vite

uttales på fransk: /vit/

https://github.com/phun-ky/