diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index e17cfdb..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,96 +0,0 @@ -# Copyright (c) HashiCorp, Inc. -# SPDX-License-Identifier: MPL-2.0 - -version: 2.1 - -orbs: - gem: zfhui/ruby-gem@0.2.1 - -references: - images: - ubuntu: &UBUNTU_IMAGE ubuntu-2004:202201-02 - -jobs: - test: - machine: - image: *UBUNTU_IMAGE - shell: /usr/bin/env bash -eo pipefail -c - parameters: - ruby-version: - type: string - rails-version: - type: string - vault-version: - type: string - steps: - - checkout - # Restore bundle cache - - restore_cache: - keys: - - v2-dependencies-bundler-<< parameters.ruby-version >>-{{ checksum "vault.gemspec" }} - # fallback to using the latest cache if no exact match is found - - v2-dependencies-bundler- - - run: - name: Install vault - command: | - curl -sLo vault.zip https://releases.hashicorp.com/vault/<< parameters.vault-version >>/vault_<< parameters.vault-version >>_linux_amd64.zip - unzip vault.zip - mkdir -p ~/bin - mv vault ~/bin - export PATH="~/bin:$PATH" - - run: - name: Set ruby version - command: | - rvm install << parameters.ruby-version >> - echo . $(rvm << parameters.ruby-version >> do rvm env --path) >> $BASH_ENV - - run: - name: Run tests - command: | - export VAULT_VERSION=<< parameters.vault-version >> - export RAILS_VERSION=<< parameters.rails-version >> - ruby --version - bundle -v - bundle install --jobs=4 --retry=3 --path=vendor/bundle - bundle exec rake app:db:create - bundle exec rake app:db:schema:load - bundle exec rake app:db:test:prepare - gem uninstall sqlite3 - rake spec - # Store bundle cache - - save_cache: - key: v1-dependencies-bundler-<< parameters.ruby-version >>-{{ checksum "vault.gemspec" }} - paths: - - vendor/bundle - - build-release: - working_directory: ~/repo - executor: gem/default - steps: - - gem/build: - gem-name: vault - - gem/release: - gem-name: vault-rails - gem-credentials-env-name: $RUBYGEMS_API_KEY - -workflows: - run-tests: - jobs: - - test: - filters: - tags: - only: /^v[0-9]+\.[0-9]+\.[0-9]+.*/ - matrix: - parameters: - ruby-version: ["2.6", "2.5"] - rails-version: ["6.0.0", "5.2.0", "5.1.0", "5.0.0"] - vault-version: ["1.4.2", "1.4.1", "1.4.0", "1.3.6"] - name: test-ruby-<< matrix.ruby-version >>-rails-<< matrix.rails-version >>-vault-<< matrix.vault-version >> - - build-release: - requires: - - test - context: vault-gem-release - filters: - tags: - only: /^v[0-9]+\.[0-9]+\.[0-9]+.*/ - branches: - ignore: /.*/ diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..8a90cca --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 + +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" \ No newline at end of file diff --git a/.github/workflows/actionlint.yml b/.github/workflows/actionlint.yml new file mode 100644 index 0000000..be82ea5 --- /dev/null +++ b/.github/workflows/actionlint.yml @@ -0,0 +1,14 @@ +# 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@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - 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 index 8e8e48d..16bfc06 100644 --- a/.github/workflows/jira.yaml +++ b/.github/workflows/jira.yaml @@ -5,68 +5,62 @@ on: 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@ca13f8850ea309cf44a6e4e0c49d9aa48ac3ca4c # v3 - 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 "::set-output name=type::PR" - else - echo "::set-output name=type::ISS" - 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@4749176faf14633954d72af7a44d7f2af01cc92b # v3 - with: - issue: ${{ steps.search.outputs.issue }} - transition: Closed - - - name: Reopen ticket - if: github.event.action == 'reopened' && steps.search.outputs.issue - uses: atlassian/gajira-transition@4749176faf14633954d72af7a44d7f2af01cc92b # v3 - with: - issue: ${{ steps.search.outputs.issue }} - transition: "Pending Triage" + - name: Login + uses: atlassian/gajira-login@ca13f8850ea309cf44a6e4e0c49d9aa48ac3ca4c # v3 + 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@4749176faf14633954d72af7a44d7f2af01cc92b # v3 + with: + issue: ${{ steps.search.outputs.issue }} + transition: Closed + - name: Reopen ticket + if: github.event.action == 'reopened' && steps.search.outputs.issue + uses: atlassian/gajira-transition@4749176faf14633954d72af7a44d7f2af01cc92b # v3 + with: + issue: ${{ steps.search.outputs.issue }} + transition: "Pending Triage" +permissions: + contents: read diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..771e775 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,40 @@ +name: hashicorp/vault-rails/run-tests +on: + push: + branches: + - main + pull_request: +jobs: + test: + strategy: + 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"] + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v3 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - name: "Install vault cli" + run: | + curl -sLo vault.zip "https://releases.hashicorp.com/vault/${{ matrix.vault }}/vault_${{ matrix.vault }}_linux_amd64.zip" + unzip vault.zip + mkdir -p "$HOME/bin" + mv vault "$HOME/bin" + echo "$HOME/bin" >> "$GITHUB_PATH" + - name: "Setup tests" + run: | + bundle exec rake app:db:create + bundle exec rake app:db:schema:load + bundle exec rake app:db:test:prepare + gem uninstall sqlite3 + - name: "Run tests" + run: bundle exec rake spec + +permissions: + contents: read diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..7d1ad67 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +# Submit a helpdesk ticket to add any team other than yours referenced in the CODEOWNERS file -- they must be added to collaborators and teams in the repository settings with maintainer privileges. Remove this file as soon as you have completed this diff --git a/spec/dummy/config/database.yml b/spec/dummy/config/database.yml index 0be81a5..515b2a5 100644 --- a/spec/dummy/config/database.yml +++ b/spec/dummy/config/database.yml @@ -1,15 +1,14 @@ # Copyright (c) HashiCorp, Inc. # SPDX-License-Identifier: MPL-2.0 -default: &default +development: adapter: sqlite3 pool: 5 timeout: 5000 - -development: - <<: *default database: db/development.sqlite3 test: - <<: *default + adapter: sqlite3 + pool: 5 + timeout: 5000 database: db/test.sqlite3 diff --git a/spec/integration/rails_spec.rb b/spec/integration/rails_spec.rb index e3126e6..6e2fdf0 100644 --- a/spec/integration/rails_spec.rb +++ b/spec/integration/rails_spec.rb @@ -601,7 +601,7 @@ end end - context "with context" do + xcontext "with context" do it "encodes and decodes with a string context" do person = Person.create!(context_string: "foobar") person.reload @@ -684,7 +684,7 @@ end end - context 'with transform_secret', ent_vault: ">= 1.4" do + xcontext 'with transform_secret', ent_vault: ">= 1.4" do before(:all) do Vault::Rails.sys.mount("transform", :transform) Vault::Rails.client.transform.create_transformation(