cloudfoundry/cf-k8s-controllers

View on GitHub
.github/workflows/test-pr.yml

Summary

Maintainability
Test Coverage
name: Run Tests on PR

on:
  pull_request:
    branches:
    - main

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:
  linter:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/cache@v4
      with:
        path: |
          ~/.cache/go-build
          ~/go/pkg/mod
        key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }}
        restore-keys: |
          ${{ runner.os }}-go-
    - uses: actions/setup-go@v5
      with:
        go-version: 'stable'
    - name: Run linters
      run: make lint

  api-tests:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4

    - uses: actions/cache@v4
      with:
        path: |
          ~/.cache/go-build
          ~/go/pkg/mod
        key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }}
        restore-keys: |
          ${{ runner.os }}-go-

    - uses: actions/setup-go@v5
      with:
        go-version: 'stable'

    - name: Run API unit tests
      run: make -C api test

  controllers-tests:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v4

    - uses: actions/cache@v4
      with:
        path: |
          ~/.cache/go-build
          ~/go/pkg/mod
        key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }}
        restore-keys: |
          ${{ runner.os }}-go-

    - uses: actions/setup-go@v5
      with:
        go-version: 'stable'

    - name: Run Controllers tests
      run: make -C controllers test

  job-task-runner-tests:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - uses: actions/cache@v4
        with:
          path: |
            ~/.cache/go-build
            ~/go/pkg/mod
          key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }}
          restore-keys: |
            ${{ runner.os }}-go-

      - uses: actions/setup-go@v5
        with:
          go-version: 'stable'

      - name: Run job-task-runner tests
        run: make -C job-task-runner test

  kpack-image-builder-tests:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - uses: actions/cache@v4
        with:
          path: |
            ~/.cache/go-build
            ~/go/pkg/mod
          key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }}
          restore-keys: |
            ${{ runner.os }}-go-

      - uses: actions/setup-go@v5
        with:
          go-version: 'stable'

      - name: Run kpack-image-builder tests
        run: make -C kpack-image-builder test

  statefulset-runner-tests:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - uses: actions/cache@v4
        with:
          path: |
            ~/.cache/go-build
            ~/go/pkg/mod
          key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }}
          restore-keys: |
            ${{ runner.os }}-go-

      - uses: actions/setup-go@v5
        with:
          go-version: 'stable'

      - name: Run statefulset-runner tests
        run: make -C statefulset-runner test

  tools-tests:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - uses: actions/cache@v4
        with:
          path: |
            ~/.cache/go-build
            ~/go/pkg/mod
          key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }}
          restore-keys: |
            ${{ runner.os }}-go-

      - uses: actions/setup-go@v5
        with:
          go-version: 'stable'

      - name: Run tools tests
        run: make -C tools test