cloudfoundry/cloud_controller_ng

View on GitHub
.github/workflows/unit_tests.yml

Summary

Maintainability
Test Coverage
name: Unit Tests
concurrency:
  group: '${{ github.workflow }}-${{ github.head_ref || github.run_id }}'
  cancel-in-progress: true
on:
  workflow_dispatch:
  pull_request:
    branches: [ main ]
    paths-ignore:
      - 'docs/**'
      - 'decisions/**'
      - '.github/workflows/docs_test.yml'
  push:
    branches: [ main ]
    paths-ignore:
      - 'docs/**'
      - 'decisions/**'
      - '.github/workflows/docs_test.yml'

permissions:
  contents: read # to fetch code (actions/checkout)

jobs:
  Rubocop:
    runs-on: ubuntu-latest
    steps:
    - uses: hmarr/debug-action@v3
    - uses: actions/checkout@v4
    - uses: ./.github/workflows/composite/setup
    - name: Run Rubocop
      run: bundle exec rake rubocop
    - uses: ravsamhq/notify-slack-action@v2
      if: github.event_name == 'push'
      with:
        status: ${{ job.status }}
        notify_when: 'failure' # default is 'success,failure,warnings'
      env:
        SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

  Test-Postgres:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    strategy:
      fail-fast: false
      matrix:
        image: ["postgres:10", "postgres:11", "postgres:16"]
    services:
      postgres:
        image: ${{ matrix.image }}
        env:
          POSTGRES_PASSWORD: rootpassword
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          - 5432:5432
    steps:
    - uses: hmarr/debug-action@v3
    - uses: actions/checkout@v4
    - uses: ./.github/workflows/composite/setup
    - name: Run tests
      run: DB=postgres POSTGRES_CONNECTION_PREFIX="postgres://postgres:rootpassword@localhost:5432" bundle exec rake spec
    - uses: ravsamhq/notify-slack-action@v2
      if: github.event_name == 'push'
      with:
        status: ${{ job.status }}
        notify_when: 'failure' # default is 'success,failure,warnings'
      env:
        SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

  Test-Mysql:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    strategy:
      fail-fast: false
      matrix:
        image: ["mysql:5.7", "mysql:8.0", "mysql:8.2"]
    services:
      mysql:
        image: ${{ matrix.image }}
        env:
          MYSQL_DATABASE: cc_test
          MYSQL_ROOT_PASSWORD: password
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
        ports:
          - 3306:3306
    steps:
    - uses: hmarr/debug-action@v3
    - uses: actions/checkout@v4
    - uses: ./.github/workflows/composite/setup
    - name: Run tests
      run: DB=mysql MYSQL_CONNECTION_PREFIX="mysql2://root:password@127.0.0.1:3306" bundle exec rake spec
    - uses: ravsamhq/notify-slack-action@v2
      if: github.event_name == 'push'
      with:
        status: ${{ job.status }}
        notify_when: 'failure' # default is 'success,failure,warnings'
      env:
        SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required