diff --git a/.github/workflows/default.yaml b/.github/workflows/default.yaml new file mode 100644 index 0000000..6f29922 --- /dev/null +++ b/.github/workflows/default.yaml @@ -0,0 +1,15 @@ +--- +name: Default + +on: + push: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build_and_publish: + name: Build and Publish + uses: wealthsimple/public-github-workflows/.github/workflows/ruby-gem-build.yaml@main + secrets: inherit diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index e85b93c..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,58 +0,0 @@ ---- -name: Pipeline -on: - push: -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - name: Build - runs-on: ubuntu-22.04 - strategy: - matrix: - ruby-version: [3.1.4, 3.2.3, 3.3.0] - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up Ruby ${{ matrix.ruby-version }} - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - ruby-version: ${{ matrix.ruby-version }} - - name: Lint - run: bundle exec rubocop - - name: Test - run: bundle exec rspec - - # Separate `release` job from `build`, as we only want release to be run once - # and not run for each ruby version in the matrix: - release: - name: Release - if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' - needs: build - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - - name: Release the gem - 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 }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 8128246..07a2c3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,15 @@ # Changelog All notable changes to this project will be documented in this file. -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +## 5.3.4 - 2024-06-14 +### Changed +- Updated dependencies + ## 5.3.3 - 2024-06-14 ### Changed - Updated dependencies @@ -169,7 +175,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Updated dependencies -### 5.0.4 - 2022-04-01 +## 5.0.4 - 2022-04-01 ### Changed - Updated workflows @@ -246,17 +252,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Migrate CI from CircleCI to GitHub Actions ## 4.0.3 - 2021-03-08 +### Changed - Update documentation to include instructions on directly publishing to SQS ## 4.0.2 - 2020-12-17 +### Changed - Bump local dev version, rubocop fixes, add backstage catalog file + sonarqube project settings ## 4.0.1 - 2020-03-23 -### Fixes +### Fixed - Fixes 4.0.0. Instead of expecting message attributes in the message from `poll`, retrieves them from the right place. ## 4.0.0 - 2020-03-18 -### Breaking Changes +### Changed - Add the ability for SQS to receive message attributes - `handle` function of `QueuePoller` now takes a third parameter `message_attributes` - blocks or `MessageHandler`s passed to `QueuePoller` can use this `message_attributes` @@ -302,6 +310,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## 2.0.1 - 2019-01-03 ### Changed - add internal gem spec to test standard gem behavior, reduces unnecessary copy and pasting + ### Fixed - namespace for the VERSION constant was incorrectly set to Ws::Ws diff --git a/Gemfile.lock b/Gemfile.lock index 2db8631..7029004 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - pheme (5.3.3) + pheme (5.3.4) activesupport (>= 4) aws-sdk-sns (~> 1.1) aws-sdk-sqs (~> 1.3) @@ -63,9 +63,12 @@ GEM minitest (5.23.1) mutex_m (0.2.0) parallel (1.25.1) + parse_a_changelog (1.3.0) + treetop (~> 1.6) parser (3.3.3.0) ast (~> 2.4.1) racc + polyglot (0.3.5) process_executer (1.1.0) public_suffix (5.0.5) racc (1.8.0) @@ -149,6 +152,8 @@ GEM rubocop-rails (~> 2.23.1) strscan (3.1.0) thor (1.3.1) + treetop (1.6.12) + polyglot (~> 0.3) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.5.0) @@ -167,6 +172,7 @@ DEPENDENCIES bundler bundler-audit git + parse_a_changelog pheme! rake rspec diff --git a/lib/pheme/version.rb b/lib/pheme/version.rb index fade8db..b289558 100644 --- a/lib/pheme/version.rb +++ b/lib/pheme/version.rb @@ -1,3 +1,3 @@ module Pheme - VERSION = '5.3.3'.freeze + VERSION = '5.3.4'.freeze end diff --git a/pheme.gemspec b/pheme.gemspec index 06e689c..e768ded 100644 --- a/pheme.gemspec +++ b/pheme.gemspec @@ -30,6 +30,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'bundler' s.add_development_dependency 'git' + s.add_development_dependency "parse_a_changelog" s.add_development_dependency 'rake' s.add_development_dependency 'rspec' s.add_development_dependency 'rspec-collection_matchers' diff --git a/spec/version_spec.rb b/spec/version_spec.rb index 6bed3e7..558f747 100644 --- a/spec/version_spec.rb +++ b/spec/version_spec.rb @@ -1,35 +1,87 @@ require 'git' +require 'parse_a_changelog' -describe Pheme do +RSpec.describe 'a published gem' do # rubocop:disable RSpec/DescribeClass def get_version(git, branch = 'HEAD') git.grep('VERSION = ', 'lib/*/version.rb', { object: branch }). map { |_sha, matches| matches.first[1] }. - filter_map { |version_string| parse_version(version_string) }. + filter_map { |str| parse_version(str) }. first + rescue Git::GitExecuteError + # Catches failures for branch name being master + nil end def parse_version(string) string.match(/VERSION = ['"](.*)['"]/)[1] end + def main_branch + @main_branch ||= + if git.branches['origin/main'] + 'origin/main' + elsif git.branches['origin/master'] + 'origin/master' + else + raise StandardError, + <<~ERROR + Couldn't determine main branch. + Does 'origin/main' or 'origin/master' need to be fetched? + ERROR + end + end + + def needs_version_bump? + base = git.merge_base(main_branch, 'HEAD').first&.sha + base ||= main_branch + git.diff(base, 'HEAD').any? { |diff| + not_gemfile?(diff) && not_dotfile?(diff) && not_docs?(diff) && not_spec?(diff) + } + end + + def not_gemfile?(diff) + ['Gemfile', 'Gemfile.lock'].exclude?(diff.path) + end + + def not_docs?(diff) + !diff.path.end_with?('.md') + end + + def not_spec?(diff) + !diff.path.start_with?('spec/') + end + + def not_dotfile?(diff) + # Ignore dotfiles, like .gitignore and CI files like .github/... + !diff.path.start_with?('.') + end + + let(:git) { Git.open('.') } + let(:head_version) { get_version(git, 'HEAD') } + it 'has a version number' do - git = Git.open('.') - head_version = get_version(git, 'HEAD') expect(head_version).not_to be_nil end - it 'has a bumped version' do - git = Git.open('.') - main_version = get_version(git, 'origin/main') + it 'has a bumped version committed' do + main_version = get_version(git, main_branch) skip('first time publishing, no need to compare versions') if main_version.nil? - is_main_branch = git.current_branch == 'main' + is_main_branch = git.current_branch == main_branch skip('already on main branch, no need to compare versions') if is_main_branch - head_version = get_version(git, 'HEAD') - puts "head_version " + head_version - raise 'no version.rb file found on the current branch' if head_version.nil? + skip('Diff only contains non-code changes, no need to bump version') unless needs_version_bump? expect(Gem::Version.new(head_version)).to be > Gem::Version.new(main_version) end + + it 'has a CHANGELOG.md file' do + expect(File).to exist('CHANGELOG.md') + end + + it 'has changelog entry for current version' do + parser = ParseAChangelog.parse('CHANGELOG.md') + versions = parser.elements[2].elements.map { |element| element.elements[1].text_value } + expect(versions.first).to include(head_version) + end end