From bc8bb3f7ddfa8fc556ebfb2246558f6e8ef03024 Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Mon, 17 Feb 2025 13:55:14 -0800 Subject: [PATCH 01/19] add a new ci job to test builds --- .github/workflows/build.yml | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..e4488abf --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,42 @@ +name: build + +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_call: + +permissions: + contents: read + +jobs: + build: + name: build + + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + + steps: + - name: checkout + uses: actions/checkout@v4 + + - uses: ruby/setup-ruby@f2f42b7848feff522ffa488a5236ba0a73bccbdd + with: + bundler-cache: true + + - name: build + run: | + GEM_NAME=$(ls | grep gemspec | cut -d. -f1) + echo "Attempting to build gem $GEM_NAME..." + gem build $GEM_NAME + if [ $? -eq 0 ]; then + echo "Gem built successfully!" + else + echo "Gem build failed!" + exit 1 + fi From a7ccf85f99422edb8e93cb35c0d7bd362c5f3bc0 Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Mon, 17 Feb 2025 13:55:23 -0800 Subject: [PATCH 02/19] add a new ci job to run a linter --- .github/workflows/lint.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..0c782ad1 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,26 @@ +name: lint + +on: + push: + branches: + - main + pull_request: + +permissions: + contents: read + +jobs: + lint: + name: lint + runs-on: ubuntu-latest + + steps: + - name: checkout + uses: actions/checkout@v4 + + - uses: ruby/setup-ruby@f2f42b7848feff522ffa488a5236ba0a73bccbdd + with: + bundler-cache: true + + - name: lint + run: bundle exec rubocop -c .rubocop.yml lib/ test/ From c69cf1e785b25623ef0b8d57483c2c9fca9cdbdb Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Mon, 17 Feb 2025 13:56:00 -0800 Subject: [PATCH 03/19] add a new ci job for automatically publishing new releases to RubyGems and GitHub Packages --- .github/workflows/release.yml | 58 +++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..465895b0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,58 @@ +name: release + +on: + workflow_dispatch: + push: + branches: + - main + paths: + - lib/version.rb + +permissions: + contents: write + packages: write + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: checkout + uses: actions/checkout@v4 + + - uses: ruby/setup-ruby@f2f42b7848feff522ffa488a5236ba0a73bccbdd + with: + bundler-cache: true + + - name: lint + run: bundle exec rubocop -c .rubocop.yml lib/ test/ + + - name: test + run: bundle exec rake + + - name: set GEM_NAME from gemspec + run: echo "GEM_NAME=$(ls | grep gemspec | cut -d. -f1)" >> $GITHUB_ENV + + # builds the gem and saves the version to GITHUB_ENV + - name: build + run: echo "GEM_VERSION=$(gem build ${{ env.GEM_NAME }}.gemspec 2>&1 | grep Version | cut -d':' -f 2 | tr -d " \t\n\r")" >> $GITHUB_ENV + + - name: publish to GitHub packages + run: | + export OWNER=$( echo ${{ github.repository }} | cut -d "/" -f 1 ) + GEM_HOST_API_KEY=${{ secrets.GITHUB_TOKEN }} gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} ${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem + + - name: release + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # pin@v1.14.0 + with: + artifacts: "${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem" + tag: "v${{ env.GEM_VERSION }}" + generateReleaseNotes: true + + - name: publish to RubyGems + run: | + mkdir -p ~/.gem + echo -e "---\n:rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}" > ~/.gem/credentials + chmod 0600 ~/.gem/credentials + gem push ${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem + rm ~/.gem/credentials From 86cc7eaa0b189ab3fb5c2e6f70936086086c605d Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Mon, 17 Feb 2025 14:05:47 -0800 Subject: [PATCH 04/19] use `lib/version.rb` for fetching the gem version to use --- lib/version.rb | 3 +++ rubocop-github.gemspec | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 lib/version.rb diff --git a/lib/version.rb b/lib/version.rb new file mode 100644 index 00000000..3ed48bc6 --- /dev/null +++ b/lib/version.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +VERSION = "0.22.0" diff --git a/rubocop-github.gemspec b/rubocop-github.gemspec index 5edd7470..a9e0c53e 100644 --- a/rubocop-github.gemspec +++ b/rubocop-github.gemspec @@ -1,8 +1,10 @@ # frozen_string_literal: true +require_relative "lib/version" + Gem::Specification.new do |s| s.name = "rubocop-github" - s.version = "0.22.0" + s.version = VERSION s.summary = "RuboCop GitHub" s.description = "Code style checking for GitHub Ruby repositories " s.homepage = "https://github.com/github/rubocop-github" From 18b9418d1aecec8e4e04be9217b4b055a1893268 Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Mon, 17 Feb 2025 14:12:44 -0800 Subject: [PATCH 05/19] remove extra whitespace --- rubocop-github.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rubocop-github.gemspec b/rubocop-github.gemspec index a9e0c53e..8d3c2b1a 100644 --- a/rubocop-github.gemspec +++ b/rubocop-github.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |s| s.name = "rubocop-github" s.version = VERSION s.summary = "RuboCop GitHub" - s.description = "Code style checking for GitHub Ruby repositories " + s.description = "Code style checking for GitHub Ruby repositories" s.homepage = "https://github.com/github/rubocop-github" s.license = "MIT" From 71058bf4cd109a35001d811bac7e2ade7edda579 Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Mon, 17 Feb 2025 14:14:43 -0800 Subject: [PATCH 06/19] add extra gem metadata --- rubocop-github.gemspec | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rubocop-github.gemspec b/rubocop-github.gemspec index 8d3c2b1a..a7f53d19 100644 --- a/rubocop-github.gemspec +++ b/rubocop-github.gemspec @@ -10,6 +10,12 @@ Gem::Specification.new do |s| s.homepage = "https://github.com/github/rubocop-github" s.license = "MIT" + s.metadata = { + "source_code_uri" => "https://github.com/github/rubocop-github", + "documentation_uri" => "https://github.com/github/rubocop-github", + "bug_tracker_uri" => "https://github.com/github/rubocop-github/issues" + } + s.files = Dir["README.md", "STYLEGUIDE.md", "LICENSE", "config/*.yml", "lib/**/*.rb", "guides/*.md"] s.add_dependency "rubocop", ">= 1.37" From c867d69aca83ecbecff8c9f02a6a15f1c1d87fa2 Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Mon, 17 Feb 2025 14:16:33 -0800 Subject: [PATCH 07/19] ensure that the CI job runs on PRs and pushes to `main` --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb34c0f3..076f5cc6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,11 @@ name: CI permissions: contents: read -on: pull_request +on: + push: + branches: + - main + pull_request: jobs: test: From f9176c8c0d644b3a34c15db3eae26d51f70bdcba Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Tue, 18 Feb 2025 21:55:28 -0800 Subject: [PATCH 08/19] update `ruby/setup-ruby` pins --- .github/workflows/build.yml | 2 +- .github/workflows/ci.yml | 4 +++- .github/workflows/lint.yml | 2 +- .github/workflows/release.yml | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e4488abf..1ae421c7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,7 +25,7 @@ jobs: - name: checkout uses: actions/checkout@v4 - - uses: ruby/setup-ruby@f2f42b7848feff522ffa488a5236ba0a73bccbdd + - uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # pin@v1.221.0 with: bundler-cache: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 076f5cc6..61b7098e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,9 +19,11 @@ jobs: - uses: actions/checkout@v4 - name: Update .ruby-version with matrix value run: echo "${{ matrix.ruby_version }}" >| .ruby-version + - name: Set up Ruby - uses: ruby/setup-ruby@f2f42b7848feff522ffa488a5236ba0a73bccbdd + uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # pin@v1.221.0 with: bundler-cache: true + - name: Run tests run: bundle exec rake diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0c782ad1..27d03efa 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,7 +18,7 @@ jobs: - name: checkout uses: actions/checkout@v4 - - uses: ruby/setup-ruby@f2f42b7848feff522ffa488a5236ba0a73bccbdd + - uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # pin@v1.221.0 with: bundler-cache: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 465895b0..85183582 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: - name: checkout uses: actions/checkout@v4 - - uses: ruby/setup-ruby@f2f42b7848feff522ffa488a5236ba0a73bccbdd + - uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # pin@v1.221.0 with: bundler-cache: true From 3bed5cb06c44ec8378059d2c0d1948200c3066ad Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Tue, 18 Feb 2025 21:56:37 -0800 Subject: [PATCH 09/19] move CODEOWNERS into `.github/` dir --- CODEOWNERS => .github/CODEOWNERS | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename CODEOWNERS => .github/CODEOWNERS (100%) diff --git a/CODEOWNERS b/.github/CODEOWNERS similarity index 100% rename from CODEOWNERS rename to .github/CODEOWNERS From 49f418990550aafbdb119bc632e97ad627c3800f Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Tue, 18 Feb 2025 21:57:36 -0800 Subject: [PATCH 10/19] fmt --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61b7098e..41ac628a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Update .ruby-version with matrix value run: echo "${{ matrix.ruby_version }}" >| .ruby-version From 61abc6bfdaf7fe5959153cd4a03931b424a621eb Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Tue, 18 Feb 2025 22:06:03 -0800 Subject: [PATCH 11/19] update release docs --- CONTRIBUTING.md | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fcab75d4..72cf0a2c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,6 @@ We welcome your contributions to the project. Thank you! Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms. - ## What to contribute This repository, `rubocop-github`, is part of a broader RuboCop ecosystem. @@ -50,12 +49,8 @@ Rubocop regularly releases new versions with new cops. We want to keep up to dat ### Releasing a new version -1. Update `rubocop-github.gemspec` with the next version number -1. Update the `CHANGELOG` with changes and contributor -1. Run `bundle` to update gem version contained in the lockfile -1. Make a commit: `Release v{VERSION}` -1. Tag the commit : `git tag v{VERSION}` -1. Create the package: `gem build rubocop-github.gemspec` -1. Push to GitHub: `git push origin && git push origin --tags` -1. Push to Rubygems: `gem push rubocop-github-{VERSION}.gem` -1. Publish a new release on GitHub: https://github.com/github/rubocop-github/releases/new +1. Update [`lib/version.rb`](lib/version.rb) with the next version number +2. Update the `CHANGELOG` with changes and contributor +3. Run `bundle` to update gem version contained in the lockfile +4. Commit your changes and open a pull request +5. When the pull request is approved and merged into `main`, the [`.github/workflows/release.yml`](.github/workflows/release.yml) workflow will automatically run to release the new version to RubyGems and GitHub Packages 🎉. From a2a42d6ef1b88a8d3734a6afcbd4ffcfc0707e51 Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Tue, 18 Feb 2025 22:21:07 -0800 Subject: [PATCH 12/19] update status badges --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 678692b8..883a19f0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,9 @@ -# RuboCop GitHub ![CI](https://github.com/github/rubocop-github/workflows/CI/badge.svg?event=push) +# RuboCop GitHub + +[![CI](https://github.com/github/rubocop-github/actions/workflows/ci.yml/badge.svg)](https://github.com/github/rubocop-github/actions/workflows/ci.yml) +[![build](https://github.com/github/rubocop-github/actions/workflows/build.yml/badge.svg)](https://github.com/github/rubocop-github/actions/workflows/build.yml) +[![lint](https://github.com/github/rubocop-github/actions/workflows/lint.yml/badge.svg)](https://github.com/github/rubocop-github/actions/workflows/lint.yml) +[![release](https://github.com/github/rubocop-github/actions/workflows/release.yml/badge.svg)](https://github.com/github/rubocop-github/actions/workflows/release.yml) This repository provides recommended RuboCop configuration and additional Cops for use on GitHub open source and internal Ruby projects, and is the home of [GitHub's Ruby Style Guide](./STYLEGUIDE.md). From 9e356c57c21da86bdfb7492dff484f0910817fba Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Wed, 19 Feb 2025 13:40:10 -0800 Subject: [PATCH 13/19] add pin comment --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6d657cf..41ac628a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: run: echo "${{ matrix.ruby_version }}" >| .ruby-version - name: Set up Ruby - uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 + uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # pin@v1.221.0 with: bundler-cache: true From 6e8f9b25eff297ad16ce9a917367f576db9be07f Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Wed, 19 Feb 2025 13:40:43 -0800 Subject: [PATCH 14/19] only run on `workflow_dispatch` events for now --- .github/workflows/release.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 85183582..9da452eb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,11 +2,11 @@ name: release on: workflow_dispatch: - push: - branches: - - main - paths: - - lib/version.rb + # push: + # branches: + # - main + # paths: + # - lib/version.rb permissions: contents: write From 13424449376f0988615675adf831fad0db57749c Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Wed, 19 Feb 2025 14:08:44 -0800 Subject: [PATCH 15/19] rename `ci` job to `test` --- .github/workflows/{ci.yml => test.yml} | 10 ++++++---- README.md | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) rename .github/workflows/{ci.yml => test.yml} (97%) diff --git a/.github/workflows/ci.yml b/.github/workflows/test.yml similarity index 97% rename from .github/workflows/ci.yml rename to .github/workflows/test.yml index 41ac628a..4c9176d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,4 @@ -name: CI -permissions: - contents: read +name: test on: push: @@ -8,13 +6,17 @@ on: - main pull_request: +permissions: + contents: read + jobs: test: + runs-on: ubuntu-latest strategy: fail-fast: false matrix: ruby_version: ["3.0", "3.1", "3.2", "3.3"] - runs-on: ubuntu-latest + steps: - uses: actions/checkout@v4 diff --git a/README.md b/README.md index 883a19f0..ed631b24 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # RuboCop GitHub -[![CI](https://github.com/github/rubocop-github/actions/workflows/ci.yml/badge.svg)](https://github.com/github/rubocop-github/actions/workflows/ci.yml) +[![test](https://github.com/github/rubocop-github/actions/workflows/test.yml/badge.svg)](https://github.com/github/rubocop-github/actions/workflows/test.yml) [![build](https://github.com/github/rubocop-github/actions/workflows/build.yml/badge.svg)](https://github.com/github/rubocop-github/actions/workflows/build.yml) [![lint](https://github.com/github/rubocop-github/actions/workflows/lint.yml/badge.svg)](https://github.com/github/rubocop-github/actions/workflows/lint.yml) [![release](https://github.com/github/rubocop-github/actions/workflows/release.yml/badge.svg)](https://github.com/github/rubocop-github/actions/workflows/release.yml) From 6bf8406592739225f59bbbe07cf4448ae28a1191 Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Wed, 19 Feb 2025 14:14:47 -0800 Subject: [PATCH 16/19] use "scripts to rule them all" pattern -> https://github.blog/engineering/scripts-to-rule-them-all/ --- .github/workflows/build.yml | 11 +---------- .github/workflows/lint.yml | 5 ++++- .github/workflows/release.yml | 9 ++++++--- .github/workflows/test.yml | 6 ++++-- .gitignore | 1 + script/bootstrap | 16 ++++++++++++++++ script/build | 15 +++++++++++++++ script/env | 32 ++++++++++++++++++++++++++++++++ script/lint | 7 +++++++ script/test | 7 +++++++ 10 files changed, 93 insertions(+), 16 deletions(-) create mode 100755 script/bootstrap create mode 100755 script/build create mode 100755 script/env create mode 100755 script/lint create mode 100755 script/test diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1ae421c7..b01a97fd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,13 +30,4 @@ jobs: bundler-cache: true - name: build - run: | - GEM_NAME=$(ls | grep gemspec | cut -d. -f1) - echo "Attempting to build gem $GEM_NAME..." - gem build $GEM_NAME - if [ $? -eq 0 ]; then - echo "Gem built successfully!" - else - echo "Gem build failed!" - exit 1 - fi + run: script/build diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 27d03efa..6412d138 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,5 +22,8 @@ jobs: with: bundler-cache: true + - name: bootstrap + run: script/bootstrap + - name: lint - run: bundle exec rubocop -c .rubocop.yml lib/ test/ + run: script/lint diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9da452eb..94eb6d8c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,16 +24,19 @@ jobs: with: bundler-cache: true + - name: bootstrap + run: script/bootstrap + - name: lint - run: bundle exec rubocop -c .rubocop.yml lib/ test/ + run: script/lint - name: test - run: bundle exec rake + run: script/test - name: set GEM_NAME from gemspec run: echo "GEM_NAME=$(ls | grep gemspec | cut -d. -f1)" >> $GITHUB_ENV - # builds the gem and saves the version to GITHUB_ENV + # builds the gem and saves the version to GITHUB_ENV - name: build run: echo "GEM_VERSION=$(gem build ${{ env.GEM_NAME }}.gemspec 2>&1 | grep Version | cut -d':' -f 2 | tr -d " \t\n\r")" >> $GITHUB_ENV diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4c9176d7..2031fa1c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,10 +23,12 @@ jobs: - name: Update .ruby-version with matrix value run: echo "${{ matrix.ruby_version }}" >| .ruby-version - - name: Set up Ruby - uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # pin@v1.221.0 + - uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # pin@v1.221.0 with: bundler-cache: true + - name: bootstrap + run: script/bootstrap + - name: Run tests run: bundle exec rake diff --git a/.gitignore b/.gitignore index fb280015..35b4f5bf 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ spec/reports test/tmp test/version_tmp tmp +bin/ # YARD artifacts .yardoc diff --git a/script/bootstrap b/script/bootstrap new file mode 100755 index 00000000..2b9fd5af --- /dev/null +++ b/script/bootstrap @@ -0,0 +1,16 @@ +#! /usr/bin/env bash + +set -e # prevent any kind of script failures + +source script/env "$@" + +# bootstrap gem dependencies +if [ "$BUNDLE_WITHOUT" == "" ]; then + echo -e "${BLUE}Installing Gems for ${PURPLE}development${BLUE}...${OFF}" +else + echo -e "${BLUE}Installing Gems for ${GREEN}production${BLUE}...${OFF}" +fi + +# what gets installed is set via the BUNDLE_WITHOUT env var in the script/env file +bundle install --local +bundle binstubs --all diff --git a/script/build b/script/build new file mode 100755 index 00000000..045a8d67 --- /dev/null +++ b/script/build @@ -0,0 +1,15 @@ +#! /usr/bin/env bash + +set -e + +source script/env "$@" + +GEM_NAME=$(ls | grep gemspec | cut -d. -f1) +echo "Attempting to build gem $GEM_NAME..." +gem build $GEM_NAME +if [ $? -eq 0 ]; then +echo "Gem built successfully!" +else +echo "Gem build failed!" +exit 1 +fi diff --git a/script/env b/script/env new file mode 100755 index 00000000..6e0dd0b5 --- /dev/null +++ b/script/env @@ -0,0 +1,32 @@ +#! /usr/bin/env bash + +set -e # prevent any kind of script failures + +# COLORS +export OFF='\033[0m' +export RED='\033[0;31m' +export GREEN='\033[0;32m' +export BLUE='\033[0;34m' +export PURPLE='\033[0;35m' + +# set RUBY_ENV to development (as a default) if not set +: "${RUBY_ENV:=development}" + +export RUBY_ENV + +# set the working directory to the root of the project +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )" +export DIR + +# set the ruby version to the one specified in the .ruby-version file +[ -z "$RBENV_VERSION" ] && RBENV_VERSION=$(cat "$DIR/.ruby-version") +export RBENV_VERSION + +# set the path to include the rbenv shims if they exist +[ -d "/usr/share/rbenv/shims" ] && export PATH=/usr/share/rbenv/shims:$PATH + +shopt -s nocasematch # enable case-insensitive matching +if [[ "$RUBY_ENV" == "production" ]]; then + export BUNDLE_WITHOUT="development" +fi +shopt -u nocasematch # disable case-insensitive matching diff --git a/script/lint b/script/lint new file mode 100755 index 00000000..e027dd34 --- /dev/null +++ b/script/lint @@ -0,0 +1,7 @@ +#! /usr/bin/env bash + +set -e + +source script/env "$@" + +bundle exec rake rubocop diff --git a/script/test b/script/test new file mode 100755 index 00000000..b75798ab --- /dev/null +++ b/script/test @@ -0,0 +1,7 @@ +#! /usr/bin/env bash + +set -e + +source script/env "$@" + +bundle exec rake test From 936e90ed8bdf94d9cabfbb2948e9b4f67ec96db7 Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Wed, 19 Feb 2025 14:15:10 -0800 Subject: [PATCH 17/19] add missing bootstrap --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b01a97fd..ff9be3aa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,5 +29,8 @@ jobs: with: bundler-cache: true + - name: bootstrap + run: script/bootstrap + - name: build run: script/build From 2dd475d2f87de70d6cc0a1db117b61600c8c2b7d Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Wed, 19 Feb 2025 15:08:34 -0800 Subject: [PATCH 18/19] add back push to main logic --- .github/workflows/release.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 94eb6d8c..012fc979 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,11 +2,11 @@ name: release on: workflow_dispatch: - # push: - # branches: - # - main - # paths: - # - lib/version.rb + push: + branches: + - main + paths: + - lib/version.rb permissions: contents: write From 91a386655afc7dcd972902df2a6370f359764c58 Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Fri, 21 Feb 2025 10:04:56 -0800 Subject: [PATCH 19/19] only use `script/test` and `script/lint` for now --- .github/workflows/build.yml | 14 ++++++++++---- .github/workflows/lint.yml | 3 --- .github/workflows/release.yml | 3 --- .github/workflows/test.yml | 7 ++----- script/bootstrap | 16 ---------------- script/build | 15 --------------- script/env | 32 -------------------------------- script/lint | 2 -- script/test | 2 -- 9 files changed, 12 insertions(+), 82 deletions(-) delete mode 100755 script/bootstrap delete mode 100755 script/build delete mode 100755 script/env diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ff9be3aa..1ae421c7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,8 +29,14 @@ jobs: with: bundler-cache: true - - name: bootstrap - run: script/bootstrap - - name: build - run: script/build + run: | + GEM_NAME=$(ls | grep gemspec | cut -d. -f1) + echo "Attempting to build gem $GEM_NAME..." + gem build $GEM_NAME + if [ $? -eq 0 ]; then + echo "Gem built successfully!" + else + echo "Gem build failed!" + exit 1 + fi diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6412d138..1df707db 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,8 +22,5 @@ jobs: with: bundler-cache: true - - name: bootstrap - run: script/bootstrap - - name: lint run: script/lint diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 012fc979..513782d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,9 +24,6 @@ jobs: with: bundler-cache: true - - name: bootstrap - run: script/bootstrap - - name: lint run: script/lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2031fa1c..7a95733d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,8 +27,5 @@ jobs: with: bundler-cache: true - - name: bootstrap - run: script/bootstrap - - - name: Run tests - run: bundle exec rake + - name: test + run: script/test diff --git a/script/bootstrap b/script/bootstrap deleted file mode 100755 index 2b9fd5af..00000000 --- a/script/bootstrap +++ /dev/null @@ -1,16 +0,0 @@ -#! /usr/bin/env bash - -set -e # prevent any kind of script failures - -source script/env "$@" - -# bootstrap gem dependencies -if [ "$BUNDLE_WITHOUT" == "" ]; then - echo -e "${BLUE}Installing Gems for ${PURPLE}development${BLUE}...${OFF}" -else - echo -e "${BLUE}Installing Gems for ${GREEN}production${BLUE}...${OFF}" -fi - -# what gets installed is set via the BUNDLE_WITHOUT env var in the script/env file -bundle install --local -bundle binstubs --all diff --git a/script/build b/script/build deleted file mode 100755 index 045a8d67..00000000 --- a/script/build +++ /dev/null @@ -1,15 +0,0 @@ -#! /usr/bin/env bash - -set -e - -source script/env "$@" - -GEM_NAME=$(ls | grep gemspec | cut -d. -f1) -echo "Attempting to build gem $GEM_NAME..." -gem build $GEM_NAME -if [ $? -eq 0 ]; then -echo "Gem built successfully!" -else -echo "Gem build failed!" -exit 1 -fi diff --git a/script/env b/script/env deleted file mode 100755 index 6e0dd0b5..00000000 --- a/script/env +++ /dev/null @@ -1,32 +0,0 @@ -#! /usr/bin/env bash - -set -e # prevent any kind of script failures - -# COLORS -export OFF='\033[0m' -export RED='\033[0;31m' -export GREEN='\033[0;32m' -export BLUE='\033[0;34m' -export PURPLE='\033[0;35m' - -# set RUBY_ENV to development (as a default) if not set -: "${RUBY_ENV:=development}" - -export RUBY_ENV - -# set the working directory to the root of the project -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )" -export DIR - -# set the ruby version to the one specified in the .ruby-version file -[ -z "$RBENV_VERSION" ] && RBENV_VERSION=$(cat "$DIR/.ruby-version") -export RBENV_VERSION - -# set the path to include the rbenv shims if they exist -[ -d "/usr/share/rbenv/shims" ] && export PATH=/usr/share/rbenv/shims:$PATH - -shopt -s nocasematch # enable case-insensitive matching -if [[ "$RUBY_ENV" == "production" ]]; then - export BUNDLE_WITHOUT="development" -fi -shopt -u nocasematch # disable case-insensitive matching diff --git a/script/lint b/script/lint index e027dd34..4c06652f 100755 --- a/script/lint +++ b/script/lint @@ -2,6 +2,4 @@ set -e -source script/env "$@" - bundle exec rake rubocop diff --git a/script/test b/script/test index b75798ab..05166157 100755 --- a/script/test +++ b/script/test @@ -2,6 +2,4 @@ set -e -source script/env "$@" - bundle exec rake test