Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Implement Continuous Delivery Pipeline (#488)
Browse files Browse the repository at this point in the history
* Add bundler to dependabot

* Rename RSpec Tests to Commit Stage

* Enable push events

* Remove pull request paths

* Rename rspec-tests to unit-tests

* Add build-release-candidate

* Rename Commit Stage to Delivery Pipeline

* Define Commit Stage

* Define Acceptance Stage

* Add Release stage

* Only upload gem for Ruby 3.2

* Move CodeQL to Commit Stage

* Rename to Delivery

Co-authored-by: Aaron Lane <2400330-aaron-lane@users.noreply.gitlab.com>
  • Loading branch information
aaron-lane and Aaron Lane authored Jan 21, 2023
1 parent ca1fabe commit f24ec65
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 215 deletions.
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ updates:
directory: "/"
schedule:
interval: "monthly"

- package-ecosystem: "bundler"
directory: "/"
schedule:
interval: "monthly"
70 changes: 0 additions & 70 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

142 changes: 142 additions & 0 deletions .github/workflows/delivery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Delivery

on:
push:
pull_request:

jobs:
commit:
name: "Commit"
if: ${{ github.ref_type == 'branch' }}
strategy:
fail-fast: false
matrix:
ruby-version:
- '2.6'
- '2.7'
- '3.0'
- '3.1'
- '3.2'
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler: '2.4'
bundler-cache: true
- name: Run RSpec Tests
if: ${{ matrix.ruby-version != '3.2' }}
run: bundle exec rake test:rspec
- name: Run RSpec Tests with Code Coverage
if: ${{ matrix.ruby-version == '3.2' }}
uses: paambaati/codeclimate-action@v3.2.0
env:
CC_TEST_REPORTER_ID: 7574433e1beed630cb9a171c688bb9e010d5028f00f7218d6e845fe138c65168
with:
coverageCommand: bundle exec rake test:rspec
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ruby
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
- name: Build Ruby Gem
if: ${{ matrix.ruby-version == '3.2' }}
env:
GEM_PRIVATE_KEY: ${{ secrets.GEM_PRIVATE_KEY }}
run: |
printf -- "${GEM_PRIVATE_KEY}\n" > certs/gem-private_key.pem
gem cert --add certs/gem-public_cert.pem
gem build kitchen-terraform.gemspec --strict --output kitchen-terraform.gem
- name: Upload Ruby Gem
if: ${{ github.event_name == 'push' && github.ref_name == 'main' && matrix.ruby-version == '3.2' }}
uses: actions/upload-artifact@v3
with:
name: ruby-gem
path: kitchen-terraform.gem

acceptance:
name: "Acceptance"
if: ${{ github.ref_type == 'branch' && github.event_name == 'push' && github.ref_name == 'main' }}
needs:
- commit
strategy:
fail-fast: false
matrix:
include:
- operating-system: macos
terraform-version: '1.1.4'
terragrunt-version: '0.36.0'
- operating-system: ubuntu
terraform-version: '0.15.5'
- operating-system: ubuntu
terraform-version: '0.14.11'
- operating-system: windows
terraform-version: '0.13.7'
runs-on: ${{ matrix.operating-system }}-latest
env:
BUNDLE_GEMFILE: gems-acceptance.rb
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Download Ruby Gem
uses: actions/download-artifact@v3
with:
name: ruby-gem
path: kitchen-terraform.gem
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
# kitchen/rake_tasks raises a `NameError: undefined method `=~'` error on Ruby 3.2
ruby-version: '3.1'
bundler: '2.4'
bundler-cache: true
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ matrix.terraform-version }}
terraform_wrapper: false
- name: Setup Terragrunt
if: ${{ matrix.operating-system == 'macos' }}
uses: autero1/action-terragrunt@v1.2.0
with:
terragrunt_version: ${{ matrix.terragrunt-version }}
- name: Mirror Terraform Providers
run: |
cd ./test/terraform/PlugIns
terraform providers mirror ./PlugInDirectory
- name: Run Kitchen Tests
run: |
bundle exec rake test:kitchen:attributes-${{ matrix.operating-system }}
bundle exec rake test:kitchen:plug-ins-${{ matrix.operating-system }}
bundle exec rake test:kitchen:variables-${{ matrix.operating-system }}
bundle exec rake test:kitchen:workspaces-${{ matrix.operating-system }}
- name: Run Kitchen Test backend-ssh
if: ${{ matrix.operating-system == 'ubuntu' }}
run: |
chmod 400 ./test/terraform/$VERSION_MATCHER/backend-ssh/id_ed25519
bundle exec rake test:kitchen:backend-ssh-ubuntu
release:
name: "Release"
if: ${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: false
- name: Download Ruby Gem
uses: actions/download-artifact@v3
with:
name: ruby-gem
path: kitchen-terraform.gem
- name: Publish
env:
GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
run: gem push kitchen-terraform.gem
67 changes: 0 additions & 67 deletions .github/workflows/kitchen-tests.yml

This file was deleted.

35 changes: 0 additions & 35 deletions .github/workflows/release.yml

This file was deleted.

43 changes: 0 additions & 43 deletions .github/workflows/rspec-tests.yml

This file was deleted.

22 changes: 22 additions & 0 deletions gems-acceptance.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

# Copyright 2016-2021 Copado NCS LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

source "https://rubygems.org/"

ruby ">= 2.6"

gem "kitchen-terraform", path: "kitchen-terraform.gem"
gem "rake", "~> 13.0"

0 comments on commit f24ec65

Please sign in to comment.