diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d99e929 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,55 @@ +name: CI + +on: + pull_request: + push: + branches: [master] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - name: Build image + run: docker compose build --pull + + - name: Lint (RuboCop) + run: docker compose run --rm api_client_builder bundle exec rubocop + + # Named container (not --rm) so coverage can be copied out afterwards. + # SimpleCov enforces its 97% minimum in-container and fails the build below. + - name: Spec + run: docker compose run --name acb_spec api_client_builder bundle exec rspec --format doc + + - name: Export coverage report + if: always() + continue-on-error: true + run: docker cp acb_spec:/usr/src/app/coverage ./coverage + + - name: Upload coverage artifact + if: always() + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage/ + if-no-files-found: ignore + + # DISABLED — brought over from the Jenkins pipeline but will not run yet. + # To enable auto-publishing to RubyGems on merge to master: + # 1. Add a `RUBYGEMS_API_KEY` repository secret (the RubyGems "rubygems-rw" API key). + # 2. Replace the `if: false` below with: if: github.ref == 'refs/heads/master' + publish: + needs: test + runs-on: ubuntu-latest + if: false + steps: + - uses: actions/checkout@v6 + + - name: Build image + run: docker compose build --pull + + - name: Publish gem to RubyGems + env: + GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} + run: docker compose run -e GEM_HOST_API_KEY --rm api_client_builder /bin/bash -lc "./bin/publish.sh" diff --git a/.rubocop.yml b/.rubocop.yml index 8fa6435..e911d65 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ AllCops: - TargetRubyVersion: 3.4 + TargetRubyVersion: 3.0 Metrics/BlockLength: Exclude: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 37422cc..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -dist: trusty -sudo: false -language: ruby -cache: bundler - -rvm: - - 2.3 - - 2.4 - - 2.5 - -matrix: - fast_finish: true - -before_install: gem update bundler -bundler_args: --jobs 3 -install: bundle install --jobs 3 - -script: - - bundle exec rubocop --fail-level autocorrect - - bundle exec rspec diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100755 index cb9c124..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,61 +0,0 @@ -pipeline { - agent { - label 'docker' - } - - options { - parallelsAlwaysFailFast() - } - - stages { - stage('Build') { - steps { - sh 'docker compose build --pull' - } - } - - stage('Spec') { - steps { - sh 'docker compose run api_client_builder bundle exec rspec --format doc' - sh ''' - image=$(docker ps --all --no-trunc | grep spec | cut -f 1 -d " " | head -n 1) - docker cp "$image:/usr/src/app/coverage" . - ''' - sh 'ls -als coverage' - } - - post { - always { - publishHTML target: [ - allowMissing: false, - alwaysLinkToLastBuild: false, - keepAll: true, - reportDir: 'coverage', - reportFiles: 'index.html', - reportName: 'Coverage Report' - ] - } - } - } - - stage('Publish') { - when { - allOf { - expression { GERRIT_BRANCH == 'master' } - environment name: 'GERRIT_EVENT_TYPE', value: 'change-merged' - } - } - steps { - withCredentials([string(credentialsId: 'rubygems-rw', variable: 'GEM_HOST_API_KEY')]) { - sh 'docker compose run -e GEM_HOST_API_KEY --rm api_client_builder /bin/bash -lc "./bin/publish.sh"' - } - } - } - } - - post { - cleanup { - sh 'docker compose down --rmi=all --volumes --remove-orphans' - } - } -}