From 2efa6547f41031d3e86add22446b925a2ff25323 Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Thu, 31 Mar 2022 14:39:40 -0500 Subject: [PATCH] Updates to make vagrant-spec work in CI * The vagrant-spec gem is installed as part of bundle install so there's no need to install it separately. Remove those extra steps and invoke it with bundle exec instead. * The binstub for vagrant does not work with `--standalone` in CI, but the one generated w/o `--standalone` works fine. This also seems to work in dev, so we'll just switch to that one. * Fetch all tags in CI to make sure we're getting proper version numbers in our build (based off `git describe`). --- .github/workflows/go-spectest.yml | 21 ++++++++++----------- binstubs/vagrant | 21 ++++++++++++++++++--- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/.github/workflows/go-spectest.yml b/.github/workflows/go-spectest.yml index 3dc6b8e13..399e14755 100644 --- a/.github/workflows/go-spectest.yml +++ b/.github/workflows/go-spectest.yml @@ -27,6 +27,9 @@ jobs: uses: actions/checkout@v2 with: submodules: 'recursive' + # Also fetch all tags, since we need our version number in the build + # to be based off a tag + fetch-depth: 0 - name: Setup Go uses: actions/setup-go@v2 with: @@ -46,17 +49,13 @@ jobs: env: HASHIBOT_USERNAME: ${{ secrets.HASHIBOT_USERNAME }} HASHIBOT_TOKEN: ${{ secrets.HASHIBOT_TOKEN }} - - name: Get vagrant-spec repo - uses: actions/checkout@v2 - with: - repository: 'hashicorp/vagrant-spec' - path: vagrant-spec - - name: Install and run vagrant-spec + - name: Add binstubs to path run: | - pushd vagrant-spec - gem build vagrant-spec.gemspec - gem install vagrant-spec-0.0.1.gem - popd - VAGRANT_PATH="$GITHUB_WORKSPACE/vagrant" vagrant-spec test --components=cli/version --config test/vagrant-spec/configs/vagrant-spec.config.virtualbox.rb + echo "$PWD/binstubs" >> $GITHUB_PATH + env: + VAGRANT_SPEC_BOX: "hashicorp/bionic64" + - name: Run vagrant-spec + run: | + VAGRANT_PATH="$GITHUB_WORKSPACE/vagrant" bundle exec vagrant-spec test --components=cli/version --config test/vagrant-spec/configs/vagrant-spec.config.virtualbox.rb env: VAGRANT_SPEC_BOX: "hashicorp/bionic64" diff --git a/binstubs/vagrant b/binstubs/vagrant index 55a2a5eed..b74047464 100755 --- a/binstubs/vagrant +++ b/binstubs/vagrant @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + # # This file was generated by Bundler. # @@ -7,8 +9,21 @@ # require "pathname" -path = Pathname.new(__FILE__) -$:.unshift File.expand_path "../..", path.realpath +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" require "bundler/setup" -load File.expand_path "../../bin/vagrant", path.realpath + +load Gem.bin_path("vagrant", "vagrant")