From 8045885b93fd621c7d3bfcddb8f6e80dd21f5c95 Mon Sep 17 00:00:00 2001 From: rumble Date: Thu, 21 Nov 2024 16:03:26 +0800 Subject: [PATCH 1/3] setup code coverage --- .github/workflows/actionlint.yml | 14 ---- .github/workflows/jira.yaml | 66 ------------------- .github/workflows/{run-tests.yml => ruby.yml} | 22 +++++-- 3 files changed, 17 insertions(+), 85 deletions(-) delete mode 100644 .github/workflows/actionlint.yml delete mode 100644 .github/workflows/jira.yaml rename .github/workflows/{run-tests.yml => ruby.yml} (62%) diff --git a/.github/workflows/actionlint.yml b/.github/workflows/actionlint.yml deleted file mode 100644 index 0a5562ba..00000000 --- a/.github/workflows/actionlint.yml +++ /dev/null @@ -1,14 +0,0 @@ -# If the repository is public, be sure to change to GitHub hosted runners -name: Lint GitHub Actions Workflows -on: - push: - pull_request: -permissions: - contents: read -jobs: - actionlint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - name: "Check workflow files" - uses: docker://docker.mirror.hashicorp.services/rhysd/actionlint:latest diff --git a/.github/workflows/jira.yaml b/.github/workflows/jira.yaml deleted file mode 100644 index 59dc90c1..00000000 --- a/.github/workflows/jira.yaml +++ /dev/null @@ -1,66 +0,0 @@ -on: - issues: - types: [opened, closed, deleted, reopened] - pull_request_target: - types: [opened, closed, reopened] - issue_comment: # Also triggers when commenting on a PR from the conversation view - types: [created] -name: Jira Sync -jobs: - sync: - runs-on: ubuntu-latest - name: Jira sync - steps: - - name: Login - uses: atlassian/gajira-login@45fd029b9f1d6d8926c6f04175aa80c0e42c9026 # v3.0.1 - env: - JIRA_BASE_URL: ${{ secrets.JIRA_SYNC_BASE_URL }} - JIRA_USER_EMAIL: ${{ secrets.JIRA_SYNC_USER_EMAIL }} - JIRA_API_TOKEN: ${{ secrets.JIRA_SYNC_API_TOKEN }} - - name: Preprocess - if: github.event.action == 'opened' || github.event.action == 'created' - id: preprocess - run: | - if [[ "${{ github.event_name }}" == "pull_request_target" ]]; then - echo "type=PR" >> "$GITHUB_OUTPUT" - else - echo "type=ISS" >> "$GITHUB_OUTPUT" - fi - - name: Create ticket - if: github.event.action == 'opened' - uses: tomhjp/gh-action-jira-create@3ed1789cad3521292e591a7cfa703215ec1348bf # v0.2.1 - with: - project: VAULT - issuetype: "GH Issue" - summary: "${{ github.event.repository.name }} [${{ steps.preprocess.outputs.type }} #${{ github.event.issue.number || github.event.pull_request.number }}]: ${{ github.event.issue.title || github.event.pull_request.title }}" - description: "${{ github.event.issue.body || github.event.pull_request.body }}\n\n_Created from GitHub Action for ${{ github.event.issue.html_url || github.event.pull_request.html_url }} from ${{ github.actor }}_" - # customfield_10089 is Issue Link custom field - # customfield_10091 is team custom field - extraFields: '{"fixVersions": [{"name": "TBD"}], "customfield_10091": ["ecosystem", "applications"], "customfield_10089": "${{ github.event.issue.html_url || github.event.pull_request.html_url }}"}' - - name: Search - if: github.event.action != 'opened' - id: search - uses: tomhjp/gh-action-jira-search@04700b457f317c3e341ce90da5a3ff4ce058f2fa # v0.2.2 - with: - # cf[10089] is Issue Link custom field - jql: 'project = "VAULT" and cf[10089]="${{ github.event.issue.html_url || github.event.pull_request.html_url }}"' - - name: Sync comment - if: github.event.action == 'created' && steps.search.outputs.issue - uses: tomhjp/gh-action-jira-comment@6eb6b9ead70221916b6badd118c24535ed220bd9 # v0.2.0 - with: - issue: ${{ steps.search.outputs.issue }} - comment: "${{ github.actor }} ${{ github.event.review.state || 'commented' }}:\n\n${{ github.event.comment.body || github.event.review.body }}\n\n${{ github.event.comment.html_url || github.event.review.html_url }}" - - name: Close ticket - if: (github.event.action == 'closed' || github.event.action == 'deleted') && steps.search.outputs.issue - uses: atlassian/gajira-transition@38fc9cd61b03d6a53dd35fcccda172fe04b36de3 # v3.0.1 - with: - issue: ${{ steps.search.outputs.issue }} - transition: Closed - - name: Reopen ticket - if: github.event.action == 'reopened' && steps.search.outputs.issue - uses: atlassian/gajira-transition@38fc9cd61b03d6a53dd35fcccda172fe04b36de3 # v3.0.1 - with: - issue: ${{ steps.search.outputs.issue }} - transition: "Pending Triage" -permissions: - contents: read diff --git a/.github/workflows/run-tests.yml b/.github/workflows/ruby.yml similarity index 62% rename from .github/workflows/run-tests.yml rename to .github/workflows/ruby.yml index 29a5605d..f012f58f 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/ruby.yml @@ -1,9 +1,14 @@ -name: hashicorp/vault-ruby/run-tests +name: Ruby on: push: - branches: - - master + paths-ignore: + - 'README.md' + - 'CHANGELOG.md' pull_request: + branches: [ master ] + paths-ignore: + - 'README.md' + - 'CHANGELOG.md' jobs: test: strategy: @@ -15,8 +20,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - uses: ruby/setup-ruby@22fdc77bf4148f810455b226c90fb81b5cbc00a7 # v1.171.0 + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Ruby + uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} bundler-cache: true # runs 'bundle install' and caches installed gems automatically @@ -28,6 +35,11 @@ jobs: mv vault "$HOME/bin" echo "$HOME/bin" >> "$GITHUB_PATH" - run: bundle exec rake + - name: Publish code coverage + if: ${{ success() && env.CC_TEST_REPORTER_ID }} + uses: paambaati/codeclimate-action@v2.7.5 + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} permissions: contents: read From 65ee9f29774533560da11a65586a2fd307024ee9 Mon Sep 17 00:00:00 2001 From: rumble Date: Thu, 21 Nov 2024 16:21:44 +0800 Subject: [PATCH 2/3] add simplecov, webrick --- Gemfile | 4 ++++ spec/spec_helper.rb | 3 +++ vault_ruby_client.gemspec | 1 + 3 files changed, 8 insertions(+) diff --git a/Gemfile b/Gemfile index 3b155adb..0c51a002 100644 --- a/Gemfile +++ b/Gemfile @@ -3,4 +3,8 @@ source "https://rubygems.org" +group :test do + gem 'simplecov', '< 0.18' +end + gemspec diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e73ccdcb..dbc54b89 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,9 @@ # Copyright (c) HashiCorp, Inc. # SPDX-License-Identifier: MPL-2.0 +require 'simplecov' +SimpleCov.start 'test_frameworks' + $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) require "vault_ruby_client" diff --git a/vault_ruby_client.gemspec b/vault_ruby_client.gemspec index 32881ea7..e605c641 100644 --- a/vault_ruby_client.gemspec +++ b/vault_ruby_client.gemspec @@ -46,4 +46,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rake", "~> 13.2" spec.add_development_dependency "rspec", "~> 3.13" spec.add_development_dependency "webmock", "~> 3.24" + spec.add_development_dependency "webrick", "~> 1.9" end From 099e6ed2e971bda59eac92ea19785265072fbb7b Mon Sep 17 00:00:00 2001 From: rumble Date: Thu, 21 Nov 2024 16:27:51 +0800 Subject: [PATCH 3/3] test newer vault version --- .github/workflows/ruby.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index f012f58f..b42d125b 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -15,8 +15,8 @@ jobs: fail-fast: false matrix: # https://endoflife.date/ruby - ruby: ["2.7", "3.0", "3.1", "3.2"] - vault: ["1.11.9", "1.12.5", "1.13.1"] + ruby: ['2.7', '3.0', '3.1', '3.2'] + vault: ['1.13.13', '1.15.5', '1.17.6'] runs-on: ubuntu-latest timeout-minutes: 5 steps: