-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#### 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
Showing
2 changed files
with
10 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters