GitHub Actions

From Torben's Wiki
Revision as of 18:22, 29 December 2022 by Torben (talk | contribs) (→‎Check new Commits and PRs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Manual, see [1]


Workflows

Check new Commits and PRs

(copy from edit mode since the display here is wrong)

# This workflow performs chapter quality (known issues) and code quality checks upon new commits and PRs.
# Configured in .pre-commit-config.yaml and setup.cfg

name: Check new commits and PRs

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

permissions:
  contents: read

jobs:
  check:

    runs-on: ubuntu-22.04

    steps:
    - name: Checkout repository
      uses: actions/checkout@v3

    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: "3.10"

    - name: Set up Python cache
      uses: actions/cache@v3
      with:
        path: $Template:Env.pythonLocation
        key: $Template:Env.pythonLocation-py-cache

    - name: Check of chapters for known issues
      run: python3 -O scripts/check-chapters.py

    - name: Check pre-commit tests
      uses: pre-commit/action@v3.0.0

Make Release, manual input

(copy from edit mode since the display here is wrong)

# This manually started workflow builds and creates a new release including the assets.

name: "Create Release" 

on:
  workflow_dispatch:
    inputs:
      version_number:
        description: 'Version number'
        required: true
        default: 'v1.2.1'
      version_text:
        description: 'Description'
        required: false
        default: 

jobs:
  release:
    runs-on: ubuntu-22.04

    steps:
    - name: Test print input
      run: |
        # env var
        echo "version_number: $Template:Github.event.inputs.version number"
        echo "version_number: $Template:Github.event.inputs.version text"

    - name: Checkout repository
      uses: actions/checkout@v3

    - name: Python set up
      uses: actions/setup-python@v4
      with:
        python-version: '3.10'

    - name: Python cache set up
      uses: actions/cache@v3
      with:
        path: $Template:Env.pythonLocation
        key: $Template:Env.pythonLocation-py-cache

    - name: Run pre-commit tests
      # configured in .pre-commit-config.yaml and setup.cfg
      uses: pre-commit/action@v3.0.0

    - name: Install requirements
      run: sh scripts/install_requirements.sh > /dev/null

    - name: Make
      run: my_make.sh
 
    - name: Create release
      uses: softprops/action-gh-release@v1
      with:
        # action var
        tag_name: "$Template:Inputs.version number"
        prerelease: false
        files: |
          ./hpmor*.pdf
          ./hpmor.epub

Tricks

Caching Python pip packages

    - name: Python set up
      uses: actions/setup-python@v4
      with:
        python-version: '3.10'

    - name: Python cache set up
      uses: actions/cache@v3
      with:
        path: $Template:Env.pythonLocation
        key: $Template:Env.pythonLocation-py-cache

Caching apt packages

    - name: Install packages using cache
      uses: awalsh128/cache-apt-pkgs-action@latest
      with:
        packages: texlive-extra-utils pandoc calibre imagemagick ghostscript
        version: 1.0
        # execute_install_scripts: true

Setup Linux environment to DE language

   - name: Setup environment to DE lang
     run: |
       cd /usr/share/locales
       sudo ./install-language-pack de_DE.UTF-8