frequenz-microgrid 0.2.2

A high-level interface to the Frequenz Microgrid API.
Documentation
name: Test PR

on:
  pull_request:

env:
  # Please make sure this version is included in the `matrix`, as the
  # `matrix` section can't use `env`, so it must be entered manually
  DEFAULT_PYTHON_VERSION: '3.11'
  # It would be nice to be able to also define a DEFAULT_UBUNTU_VERSION
  # but sadly `env` can't be used either in `runs-on`.

jobs:
  protolint:
    name: Check proto files with protolint
    runs-on: ubuntu-24.04

    steps:
      - name: Setup Git
        uses: frequenz-floss/gh-action-setup-git@v1.0.0

      - name: Fetch sources
        uses: actions/checkout@v4
        with:
          submodules: true

      - name: Run protolint
        # Only use hashes here, as we are passing the github token, we want to
        # make sure updates are done consciously to avoid security issues if the
        # action repo gets hacked
        uses: yoheimuta/action-protolint@e62319541dc5107df5e3a5010acb8987004d3d25 # v1.3.0
        with:
          fail_on_error: true
          filter_mode: nofilter
          github_token: ${{ secrets.github_token }}
          protolint_flags: proto/
          protolint_version: "0.53.0"
          reporter: github-check

  protoc:
    name: Test with protoc
    runs-on: ubuntu-24.04
    steps:
      - name: Fetch sources
        uses: actions/checkout@v4
        with:
          submodules: true
      - name: Source protoc
        run: |
          curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v25.1/protoc-25.1-linux-x86_64.zip
          mkdir protoc
          unzip protoc-25.1-linux-x86_64.zip -d protoc
          sudo cp -r protoc/bin/* /usr/bin/
          sudo cp -r protoc/include/* /usr/include/
          rm -r protoc-25.1-linux-x86_64.zip protoc
      - name: Run sanity tests
        run: |
          protoc \
          --fatal_warnings \
          -I proto \
          -I submodules/frequenz-api-common/proto \
          -I submodules/api-common-protos \
          --python_out=. \
          frequenz/api/microgrid/v1/microgrid.proto

  nox:
    name: Test with nox
    runs-on: ubuntu-24.04

    steps:
      - name: Run nox
        uses: frequenz-floss/gh-action-nox@v1.0.0
        with:
          python-version: "3.11"
          nox-session: ci_checks_max

  test-docs:
    name: Test documentation website generation
    runs-on: ubuntu-24.04
    steps:
      - name: Setup Git
        uses: frequenz-floss/gh-action-setup-git@v1.0.0

      - name: Fetch sources
        uses: actions/checkout@v4
        with:
          submodules: true

      - name: Setup Python
        uses: frequenz-floss/gh-action-setup-python-with-deps@v1.0.0
        with:
          python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
          dependencies: .[dev-mkdocs]

      - name: Generate the documentation
        env:
          MIKE_VERSION: gh-${{ github.job }}
        run: |
          mike deploy $MIKE_VERSION
          mike set-default $MIKE_VERSION

      - name: Upload site
        uses: actions/upload-artifact@v4
        with:
          name: docs-site
          path: site/
          if-no-files-found: error