Skip to content

Commit

Permalink
chore: use reusable workflow (#74)
Browse files Browse the repository at this point in the history
#### Why <!-- A short description of why this change is required -->
Standardizing our ruby gem repository setup (CI and version spec)


#### What changed <!-- Summary of changes when modifying hundreds of
lines -->
- Use reusable workflow
- Bring version spec up to date


<!--
Consider adding the following sections:

#### How I tested [ Bullets for test cases covered ]
#### Next steps [ If your PR is part of a few or a WIP, give context to
reviewers ]
#### Screenshot [ An image is worth a thousand words ]
#### Bug/Ticket tracker [ Unnecessary when prefixing branch with JIRA
ticket, e.g. SECURITY-123-human-readable-thing ]
-->
  • Loading branch information
rperryng authored Jul 2, 2024
1 parent 12e6daf commit 75e862f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 64 deletions.
72 changes: 9 additions & 63 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
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
2 changes: 1 addition & 1 deletion spec/eventsimple_spec.rb → spec/version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 75e862f

Please sign in to comment.