From db73776567bc1c73147a8ca44905f25986c64140 Mon Sep 17 00:00:00 2001 From: "Garen J. Torikian" Date: Tue, 15 Nov 2022 10:50:15 -0300 Subject: [PATCH 1/3] Address typos in CLI --- lib/html_proofer/configuration.rb | 8 ++++---- spec/html-proofer/command_spec.rb | 11 +++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/html_proofer/configuration.rb b/lib/html_proofer/configuration.rb index ce986322..4f789ea3 100644 --- a/lib/html_proofer/configuration.rb +++ b/lib/html_proofer/configuration.rb @@ -197,12 +197,12 @@ def parse_cli_options(args) @options[long_opt_symbol] = parse_json_option("typhoeus", arg, symbolize_names: false) end - set_option(opts, "--hydra ") do |long_opt_symbol, _list| - @options[long_opt_symbol] = parse_json_option("hydra", arg, symbolize_names: false) + set_option(opts, "--hydra ") do |long_opt_symbol, arg| + @options[long_opt_symbol] = parse_json_option("hydra", arg, symbolize_names: true) end - set_option(opts, "--cache ") do |long_opt_symbol, _list| - @options[long_opt_symbol] = parse_json_option("cache", arg, symbolize_names: false) + set_option(opts, "--cache ") do |long_opt_symbol, arg| + @options[long_opt_symbol] = parse_json_option("cache", arg, symbolize_names: true) end end diff --git a/spec/html-proofer/command_spec.rb b/spec/html-proofer/command_spec.rb index 15cba4fb..12c4ac78 100644 --- a/spec/html-proofer/command_spec.rb +++ b/spec/html-proofer/command_spec.rb @@ -222,6 +222,17 @@ it "supports hydra" do http = make_bin(%(--hydra '{"max_concurrency": 5}' http://www.github.com --as-links)) expect(http.scan(/max_concurrency is invalid/).count).to(eq(0)) + expect(http.scan(/successfully/).count).to(eq(1)) + end + end + + context "when dealing with cache" do + it "basically works" do + new_time = Time.local(2022, 1, 6, 12, 0, 0) + Timecop.freeze(new_time) do + http = make_bin(%(--cache '{"timeframe": { "external": "1d"}}' http://www.github.com --as-links)) + expect(http.scan(/successfully/).count).to(eq(1)) + end end end end From 7cf2aa30db124aba93047fdd9cd53efd4ed904eb Mon Sep 17 00:00:00 2001 From: "Garen J. Torikian" Date: Tue, 15 Nov 2022 10:55:48 -0300 Subject: [PATCH 2/3] Update workflows --- .github/dependabot.yml | 22 +++++++-- .github/workflows/automerge.yml | 34 +++++++++++++ .github/workflows/lint.yml | 3 ++ .github/workflows/tag_and_release.yml | 70 +++++++++++++++++++++++++++ .github/workflows/test.yml | 8 ++- Gemfile | 2 + script/generate_changelog | 2 +- 7 files changed, 131 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/automerge.yml create mode 100644 .github/workflows/tag_and_release.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 203f3c88..be466a31 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,6 +1,20 @@ version: 2 updates: -- package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "weekly" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: daily + time: "09:00" + timezone: "Etc/UTC" + open-pull-requests-limit: 10 + + - package-ecosystem: "bundler" + directory: "/" + schedule: + interval: daily + time: "09:00" + timezone: "Etc/UTC" + open-pull-requests-limit: 10 + allow: + - dependency-name: "*" + dependency-type: "production" diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 00000000..4b61205e --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,34 @@ +name: PR auto-{approve,merge} + +on: + pull_request_target: + +permissions: + pull-requests: write + contents: write + +jobs: + dependabot: + name: Dependabot + runs-on: ubuntu-latest + + if: ${{ github.actor == 'dependabot[bot]' }} + steps: + - name: Fetch Dependabot metadata + id: dependabot-metadata + uses: dependabot/fetch-metadata@v1 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Approve Dependabot PR + if: ${{steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major'}} + run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Merge Dependabot PR + run: gh pr merge --auto --squash "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index de67d9d6..fceb2ae9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,10 +11,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - uses: ruby/setup-ruby@v1 with: ruby-version: 3.1 bundler-cache: true + - run: bundle install + - name: Rubocop run: bundle exec rake rubocop diff --git a/.github/workflows/tag_and_release.yml b/.github/workflows/tag_and_release.yml new file mode 100644 index 00000000..f03d530b --- /dev/null +++ b/.github/workflows/tag_and_release.yml @@ -0,0 +1,70 @@ +name: Tag and Release + +on: + workflow_dispatch: + push: + branches: + - main + paths: + - "lib/html_proofer/version.rb" + +jobs: + release: + env: + GEM_NAME: tailwind_merge + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_BOT_KEY }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Ruby 3.1 + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.1 + bundler-cache: true + + - name: Configure Git + run: | + git config --local user.email "actions@github.com" + git config --local user.name "Actions Auto Build" + + - name: Get current version + id: version-label + run: | + VERSION=$(grep VERSION lib/html_proofer/version.rb | head -n 1 | cut -d'"' -f2) + echo "version=${VERSION}" >> $GITHUB_OUTPUT + + - name: Create tag + run: | + git tag -a v${{ steps.version-label.outputs.version }} -m "Release v${{ steps.version-label.outputs.version }}" + git push origin --tags + + - name: Generate CHANGELOG.md + id: changelog + run: script/generate_changelog + + - name: Commit & Push Changelog + run: | + git config --local user.email "actions@github.com" + git config --local user.name "Actions Auto Build" + git add -f CHANGELOG.md + git commit -m "docs: update changelog" || true + git push + + - name: Publish release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create v${{ steps.version-label.outputs.version }} --generate-notes + + - name: Publish to RubyGems + run: | + mkdir -p $HOME/.gem + touch $HOME/.gem/credentials + chmod 0600 $HOME/.gem/credentials + printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials + bundle exec rake package + for gem in pkg/html-proofer-${{ steps.version-label.outputs.version }}*.gem ; do + gem push "$gem" --host https://rubygems.org + done diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8da60b37..f3ca3e6d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,9 +2,6 @@ name: Test on: pull_request: - push: - branches: - - main permissions: contents: read @@ -17,14 +14,15 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Install libxslt and libxml2 - run: sudo apt-get install libxslt-dev libxml2-dev + - name: Set up Ruby 3.1 uses: ruby/setup-ruby@v1 with: ruby-version: 3.1 bundler-cache: true + - name: Install dependencies run: bundle install + - name: Run tests run: bundle exec rake diff --git a/Gemfile b/Gemfile index 6f56e044..b3c36c8c 100644 --- a/Gemfile +++ b/Gemfile @@ -5,3 +5,5 @@ source "https://rubygems.org" gemspec gem "ruby-lsp", "~> 0.3.2", group: :development + +gem "github_changelog_generator", "~> 1.16" diff --git a/script/generate_changelog b/script/generate_changelog index 8814ace5..9e75a048 100755 --- a/script/generate_changelog +++ b/script/generate_changelog @@ -1,3 +1,3 @@ #!/bin/sh -CHANGELOG_GITHUB_TOKEN="$GITHUB_CHANGELOG_TOKEN" github_changelog_generator -u gjtorikian -p html-proofer + CHANGELOG_GITHUB_TOKEN="$GITHUB_TOKEN" bundle exec github_changelog_generator -u gjtorikian -p tailwind_merge From 4ea53f81d35f772dae844beb9380ab4c142c155e Mon Sep 17 00:00:00 2001 From: "Garen J. Torikian" Date: Tue, 15 Nov 2022 10:56:32 -0300 Subject: [PATCH 3/3] :gem: bump to 5.0.2 --- lib/html_proofer/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/html_proofer/version.rb b/lib/html_proofer/version.rb index 16c3e7dc..6dcd8598 100644 --- a/lib/html_proofer/version.rb +++ b/lib/html_proofer/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module HTMLProofer - VERSION = "5.0.1" + VERSION = "5.0.2" end