name: Testing

on: [push, pull_request]

jobs:
  testing:
    runs-on: macos-15
    steps:
    - uses: actions/checkout@v4
    - uses: ruby/setup-ruby@v1
      with:
        ruby-version: '3.3'
        bundler-cache: true
    - name: Setup Go
      uses: actions/setup-go@v5
      with:
        go-version: '1.23.x'
    - name: Installing packages
      run: |
        gem install bundler
    - uses: actions/cache@v4
      id: gopenpgp-cache
      with:
        path: go
        key: ${{ runner.os }}-gopenpgp-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/gopenpgp_build.sh') }}
    - name: Bundle Install
      run: |
        bundle config path vendor/bundle
        bundle install --jobs 4 --retry 3
    - name: GopenPGP
      if: ${{ steps.gopenpgp-cache.outputs.cache-hit == false }}
      run: ./scripts/gopenpgp_build.sh
    - name: Testing
      run: bundle exec fastlane test
