diff options
author | ciprianbadescu <51971875+ciprianbadescu@users.noreply.github.com> | 2022-01-06 15:22:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-06 15:22:04 +0200 |
commit | 49d0c59fd7ba8a6d6ae081d78a0c08dbf76f8584 (patch) | |
tree | 67712cb768f3004c40939a4d5e22cedbdbe94956 | |
parent | 76f9617f58f01b2b1d5e46fb315f0951d469c467 (diff) | |
parent | c2a4f7cd15f380233bcf8aff5af304bdd0f47d4f (diff) | |
download | puppet-sshkeys_core-49d0c59fd7ba8a6d6ae081d78a0c08dbf76f8584.tar.gz puppet-sshkeys_core-49d0c59fd7ba8a6d6ae081d78a0c08dbf76f8584.tar.bz2 |
Merge pull request #55 from luchihoratiu/main
(MODULES-11073) Gather and set output data in GHA workflow
-rw-r--r-- | .github/workflows/daily_unit_tests_with_nightly_puppet_gem.yaml | 68 | ||||
-rw-r--r-- | .github/workflows/dispatch_unit_tests_with_nightly_puppet_gem.yaml | 129 |
2 files changed, 129 insertions, 68 deletions
diff --git a/.github/workflows/daily_unit_tests_with_nightly_puppet_gem.yaml b/.github/workflows/daily_unit_tests_with_nightly_puppet_gem.yaml deleted file mode 100644 index fa160c7..0000000 --- a/.github/workflows/daily_unit_tests_with_nightly_puppet_gem.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -name: '[Daily] Unit Tests with nightly Puppet gem' - -on: - workflow_dispatch: - -jobs: - daily_unit_tests_with_nightly_puppet_gem: - name: ${{ matrix.os_type }} / Puppet${{ matrix.puppet_version }} gem / Ruby ${{ matrix.ruby }} - strategy: - matrix: - os: [ 'ubuntu-18.04', 'macos-10.15', 'windows-2016' ] - puppet_version: [ 6, 7 ] - include: - - puppet_version: 6 - ruby: 2.5 - - puppet_version: 7 - ruby: 2.7 - - - os: 'ubuntu-18.04' - os_type: 'Linux' - env_set_cmd: 'export ' - gem_file: 'puppet-latest.gem' - - os: 'macos-10.15' - os_type: 'macOS' - env_set_cmd: 'export ' - gem_file: 'puppet-latest-universal-darwin.gem' - - os: 'windows-2016' - os_type: 'Windows' - env_set_cmd: '$env:' - gem_file: 'puppet-latest-x64-mingw32.gem' - - runs-on: ${{ matrix.os }} - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Install ruby version ${{ matrix.ruby }} - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - - - name: Install the latest nightly build of puppet${{ matrix.puppet_version }} gem - run: | - curl http://nightlies.puppet.com/downloads/gems/puppet${{ matrix.puppet_version }}-nightly/${{ matrix.gem_file }} --output puppet.gem - gem install puppet.gem -N - - - name: Prepare testing environment with bundler - run: | - git config --global core.longpaths true - bundle config set system 'true' - bundle config set --local without 'release' - ${{ matrix.env_set_cmd }}PUPPET_GEM_VERSION=$(ruby -e 'puts /puppet\s+\((.+)\)/.match(`gem list -eld puppet`)[1]') - bundle update --jobs 4 --retry 3 - - - name: Run unit tests - run: bundle exec rake parallel_spec - - notify-via-slack: - name: Notify workflow conclusion via Slack - if: ${{ always() }} - needs: daily_unit_tests_with_nightly_puppet_gem - runs-on: 'ubuntu-latest' - steps: - - uses: luchihoratiu/notify-via-slack@main - with: - SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }} - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/dispatch_unit_tests_with_nightly_puppet_gem.yaml b/.github/workflows/dispatch_unit_tests_with_nightly_puppet_gem.yaml new file mode 100644 index 0000000..a0b2248 --- /dev/null +++ b/.github/workflows/dispatch_unit_tests_with_nightly_puppet_gem.yaml @@ -0,0 +1,129 @@ +--- +name: '[Dispatched] Unit Tests with nightly Puppet gem' + +on: + workflow_dispatch: + inputs: + pa_ref: + description: 'Puppet Agent SHA to use in this run' + +jobs: + set_output_data: + name: 'Prepare input and output data' + runs-on: 'ubuntu-latest' + outputs: + puppet_sha: ${{ steps.setup_world.outputs.puppet_sha }} + ruby_version: ${{ steps.setup_world.outputs.ruby_version }} + puppet_version: ${{ steps.setup_world.outputs.puppet_version }} + puppet_short_commit: ${{ steps.setup_world.outputs.puppet_short_commit }} + + steps: + - name: Gather and set data + id: setup_world + run: | + pa_ref=${{ github.event.inputs.pa_ref }} + res=$(curl -s https://raw.githubusercontent.com/puppetlabs/puppet-agent/${pa_ref}/configs/components/puppet.json) + + puppet_remote=$(echo $res | cut -d '"' -f 4) + puppet_sha=$(echo $res | cut -d '"' -f 8) + + mkdir puppet + pushd puppet + git init + git remote add origin ${puppet_remote} + git fetch + puppet_short_commit=$(git describe ${puppet_sha} | sed -r 's/-/./g' | rev | cut -c 4- | rev) + puppet_version=${puppet_short_commit:0:1} + popd + rm -rf puppet + + case $puppet_version in + 6) + ruby_version='2.5' + ;; + 7) + ruby_version='2.7' + ;; + esac + + echo "::set-output name=puppet_sha::$puppet_sha" + echo "::set-output name=ruby_version::$ruby_version" + echo "::set-output name=puppet_version::$puppet_version" + echo "::set-output name=puppet_short_commit::$puppet_short_commit" + + - name: "Puppet Agent SHA: ${{ github.event.inputs.pa_ref }}" + run: "echo ${{ github.event.inputs.pa_ref }}" + + - name: "Puppet SHA: ${{ steps.setup_world.outputs.puppet_sha }}" + run: "echo ${{ steps.setup_world.outputs.puppet_sha }}" + + - name: "Puppet Short Commit: ${{ steps.setup_world.outputs.puppet_short_commit }}" + run: "echo ${{ steps.setup_world.outputs.puppet_short_commit }}" + + - name: "Puppet Version: ${{ steps.setup_world.outputs.puppet_version }}" + run: "echo ${{ steps.setup_world.outputs.puppet_version }}" + + - name: "Ruby Version: ${{ steps.setup_world.outputs.ruby_version }}" + run: "echo ${{ steps.setup_world.outputs.ruby_version }}" + + unit_tests_with_nightly_puppet_gem: + name: ${{ matrix.os_type }} / Puppet${{ needs.set_output_data.outputs.puppet_version }} gem / Ruby${{ needs.set_output_data.outputs.ruby_version }} + needs: set_output_data + env: + puppet_version: ${{ needs.set_output_data.outputs.puppet_version }} + ruby_version: ${{ needs.set_output_data.outputs.ruby_version }} + + strategy: + matrix: + os: [ 'ubuntu-18.04', 'macos-10.15', 'windows-2016' ] + include: + - os: 'ubuntu-18.04' + os_type: 'Linux' + env_set_cmd: 'export ' + gem_file_postfix: '.gem' + - os: 'macos-10.15' + os_type: 'macOS' + env_set_cmd: 'export ' + gem_file_postfix: '-universal-darwin.gem' + - os: 'windows-2016' + os_type: 'Windows' + env_set_cmd: '$env:' + gem_file_postfix: '-x64-mingw32.gem' + + runs-on: ${{ matrix.os }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install ruby version ${{ env.ruby_version }} + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ env.ruby_version }} + + - name: Install the latest nightly build of puppet${{ env.puppet_version }} gem + run: | + curl http://nightlies.puppet.com/downloads/gems/puppet${{ env.puppet_version }}-nightly/puppet-${{ needs.set_output_data.outputs.puppet_short_commit }}${{ matrix.gem_file_postfix }} --output puppet.gem + gem install puppet.gem -N + + - name: Prepare testing environment with bundler + run: | + git config --global core.longpaths true + bundle config set system 'true' + bundle config set --local without 'release' + + ${{ matrix.env_set_cmd }}PUPPET_GEM_VERSION=${{ needs.set_output_data.outputs.puppet_short_commit }} + bundle update --jobs 4 --retry 3 + + - name: Run unit tests + run: bundle exec rake parallel_spec + + notify-via-slack: + name: Notify workflow conclusion via Slack + if: ${{ always() }} + needs: unit_tests_with_nightly_puppet_gem + runs-on: 'ubuntu-latest' + steps: + - uses: luchihoratiu/notify-via-slack@main + with: + SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |