otiai10/gosseract

View on GitHub
.github/workflows/go-ci.yml

Summary

Maintainability
Test Coverage
name: Go Test

on:
  workflow_dispatch:
  schedule:
    - cron: '0 0 * * 5'
  push:
    branches: [main, develop]
  pull_request:
    branches: [main, develop]

jobs:
  macos:
    strategy:
      matrix:
        os: [macos-latest]
        go: ['1.19', '1.20', '1.21']
    runs-on: ${{ matrix.os }}
    name: macOS Go${{ matrix.go }} on ${{ matrix.os }}
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Go
        uses: actions/setup-go@v4
        with:
          go-version: ${{ matrix.go }}
      - name: Install tesseract
        run: brew install tesseract
      - name: Install pkg
        run: go get -u -v -t ./...
      - name: Test
        run: go test -v -cover ./...
  coverage:
    runs-on: ubuntu-latest
    name: Ubuntu for Coverage
    needs: macos
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Go
        uses: actions/setup-go@v4
        with:
          go-version: '1.18'
      - name: Install packages
        run: |
          sudo apt-get update
          sudo apt-get install -y \
            libtesseract-dev \
            libleptonica-dev \
            tesseract-ocr-eng
      - name: Coverage Test
        run: go test -v -cover -race -coverprofile=coverage -covermode=atomic
      - name: Upload coverage
        uses: codecov/codecov-action@v4
        with:
          file: ./coverage
          token: ${{ secrets.CODECOV_TOKEN }}