From 75e862f0ff73f4b148a319963960eb65809cb368 Mon Sep 17 00:00:00 2001 From: Ryan Perry-Nguyen Date: Tue, 2 Jul 2024 09:41:52 -0400 Subject: [PATCH] chore: use reusable workflow (#74) #### Why Standardizing our ruby gem repository setup (CI and version spec) #### What changed - Use reusable workflow - Bring version spec up to date --- .github/workflows/default.yml | 72 +++---------------- spec/{eventsimple_spec.rb => version_spec.rb} | 2 +- 2 files changed, 10 insertions(+), 64 deletions(-) rename spec/{eventsimple_spec.rb => version_spec.rb} (97%) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 058003bb0..d3ab38a88 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -1,71 +1,17 @@ --- name: Default + on: - - push + push: + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: - build: - name: Build - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 0 - - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - - name: Fetch main branch - run: git fetch origin main - - uses: r7kamura/rubocop-problem-matchers-action@v1 - - name: Lint - run: | - bundle exec rubocop - bundle exec bundle-audit update - bundle exec bundle-audit check - - name: Run database container - run: | - docker run \ - --detach \ - --name eventsimple_postgresql \ - -e POSTGRES_HOST_AUTH_METHOD=trust \ - -p 5432:5432 \ - --health-cmd pg_isready \ - --health-interval 10s \ - --health-timeout 5s \ - --health-retries 5 \ - postgres:15-alpine \ - postgres -c 'max_connections=300' - - name: Setup databases - run: bundle exec rake db:setup - - name: Run rspec - run: bundle exec rspec - - name: Check if version has changed - if: ${{ github.ref == 'refs/heads/main' }} - id: version-check - run: | - if [ "$(git diff --name-only HEAD^ HEAD | grep 'lib/eventsimple/version.rb')" ]; then - echo "Version did change" - echo "version_changed=true" >> $GITHUB_OUTPUT - else - echo "Version did not change" - echo "version_changed=false" >> $GITHUB_OUTPUT - fi - - name: Release the gem - if: ${{ github.ref == 'refs/heads/main' && steps.version-check.outputs.version_changed == 'true' }} - run: | - mkdir -p ~/.gem - cat << EOF > ~/.gem/credentials - --- - :github: Bearer ${GITHUB_TOKEN} - :rubygems_api_key: ${RUBYGEMS_API_KEY} - EOF - chmod 0600 ~/.gem/credentials - git config user.email "noreply@wealthsimple.com" - git config user.name "Wolfbot" - bundle exec rake release - env: - RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} + build_and_publish: + name: Build and Publish + uses: wealthsimple/public-github-workflows/.github/workflows/ruby-gem-build.yaml@main + with: + postgres_image: 'postgres:14-alpine' + secrets: inherit diff --git a/spec/eventsimple_spec.rb b/spec/version_spec.rb similarity index 97% rename from spec/eventsimple_spec.rb rename to spec/version_spec.rb index 558f74777..3923d9209 100644 --- a/spec/eventsimple_spec.rb +++ b/spec/version_spec.rb @@ -40,7 +40,7 @@ def needs_version_bump? end def not_gemfile?(diff) - ['Gemfile', 'Gemfile.lock'].exclude?(diff.path) + !['Gemfile', 'Gemfile.lock'].include?(diff.path) end def not_docs?(diff)