diff --git a/.github/workflows/proxy_integration_tests.yml b/.github/workflows/proxy_integration_tests.yml index 9f6bcd3..045a1d1 100644 --- a/.github/workflows/proxy_integration_tests.yml +++ b/.github/workflows/proxy_integration_tests.yml @@ -28,6 +28,9 @@ jobs: bundler-cache: true ruby-version: ruby + - name: Build the gem + run: gem build ruby-proxy-headers.gemspec + - name: Require PROXY_URL Actions secret env: PROXY_URL: ${{ secrets.PROXY_URL }} diff --git a/scripts/check-version.sh b/scripts/check-version.sh new file mode 100755 index 0000000..9e5ff1b --- /dev/null +++ b/scripts/check-version.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# Check that version.rb and Gemfile.lock carry the same gem version, and that +# a release/X.Y.Z branch carries version X.Y.Z. scripts/lint.sh runs this; +# on pull requests the branch comes from GITHUB_HEAD_REF. + +set -euo pipefail + +err() { + echo "$*" >&2 +} + +main() { + cd "$(git rev-parse --show-toplevel)" + local version lock branch + version="$(sed -nE "s/^ *VERSION = '([^']+)'$/\1/p" \ + lib/ruby_proxy_headers/version.rb)" + lock="$(sed -nE 's/^ ruby-proxy-headers \(([^)]+)\)$/\1/p' Gemfile.lock)" + branch="${GITHUB_HEAD_REF:-$(git rev-parse --abbrev-ref HEAD)}" + if [[ -z "${version}" || "${lock}" != "${version}" ]]; then + err "version.rb '${version}' != Gemfile.lock '${lock}'; run bundle install" + exit 1 + fi + if [[ "${branch}" == release/* && "${branch#release/}" != "${version}" ]]; then + err "branch ${branch} != version.rb ${version}" + exit 1 + fi +} + +main "$@" diff --git a/scripts/lint.sh b/scripts/lint.sh index d5c38bb..7f134c0 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -44,6 +44,7 @@ main() { fi check shellcheck shellcheck "${sh_files[@]}" check shfmt shfmt -d -i 2 -ci "${sh_files[@]}" + check version scripts/check-version.sh check rubocop bundle exec rubocop if ((${#failed[@]} > 0)); then