Skip to content

Commit 2dd5c49

Browse files
jpogranglennsarti
authored andcommitted
(maint) Use GitHub actions instead of Travis and AppVeyor
Due to Travis CI changing its CI limits it is no longer functioning for this project. This commit: * Migrates both Travis and Appveyor CI to GitHubActions * Uses a small PowerShell script to generate the test matrix due to the limitations of Workflow YAML * Adds a build and artifact test phase, with a limited retention period
1 parent 95781f6 commit 2dd5c49

File tree

4 files changed

+152
-140
lines changed

4 files changed

+152
-140
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#Requires -Version 7
2+
param([Switch]$Raw)
3+
$Jobs = @()
4+
5+
# All default OSes we test on
6+
$OSList =@('ubuntu-latest', 'windows-latest')
7+
# All default Ruby and Puppet combinations
8+
$RubyPuppet = @(
9+
@{ ruby = '2.7'; puppet_gem_version = '~> 7.0' }
10+
@{ ruby = '2.5'; puppet_gem_version = '~> 6.0' }
11+
@{ ruby = '2.4'; puppet_gem_version = '~> 5.0' }
12+
)
13+
14+
$OSList | ForEach-Object {
15+
$OS = $_
16+
17+
# Add Rubocop tests
18+
$Jobs += @{
19+
job_name = 'Lint'
20+
os = $OS
21+
ruby = $RubyPuppet[0].ruby
22+
puppet_gem_version = ">= 0.0"
23+
rake_tasks = 'rubocop'
24+
}
25+
26+
# Add the generic unit tests for all Ruby Puppet combinations
27+
$RubyPuppet | ForEach-Object {
28+
$Jobs += @{
29+
job_name = 'Unit Test'
30+
os = $OS
31+
ruby = $_.ruby
32+
puppet_gem_version = $_.puppet_gem_version
33+
rake_tasks = 'gem_revendor test_languageserver test_languageserver_sidecar test_debugserver'
34+
}
35+
}
36+
37+
# Add Version specific Tests
38+
$Jobs += @{
39+
job_name = 'Puppet 5.1.0 Unit Test'
40+
os = $OS
41+
ruby = "2.4"
42+
puppet_gem_version = "5.1.0"
43+
rake_tasks = 'gem_revendor test_languageserver'
44+
}
45+
46+
# Add Acceptance tests
47+
$Jobs += @{
48+
job_name = 'Acceptance Test'
49+
os = $OS
50+
ruby = $RubyPuppet[0].ruby
51+
puppet_gem_version = $RubyPuppet[0].puppet_gem_version
52+
rake_tasks = 'gem_revendor acceptance_languageserver'
53+
}
54+
}
55+
56+
if ($Raw) {
57+
Write-Host ($Jobs | ConvertTo-JSON)
58+
} else {
59+
# Output the result for consumption by GH Actions
60+
Write-Host "::set-output name=matrix::$($Jobs | ConvertTo-JSON -Compress))"
61+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Editor Services CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
matrix:
13+
name: Generate test matrix
14+
runs-on: ubuntu-latest
15+
outputs:
16+
matrix: ${{ steps.set-matrix.outputs.matrix }}
17+
steps:
18+
- uses: actions/checkout@v2
19+
- id: set-matrix
20+
shell: pwsh
21+
# Use a small PowerShell script to generate the test matrix
22+
run: "& .github/workflows/create-test-matrix.ps1"
23+
24+
run-tests:
25+
needs: [matrix]
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
cfg: ${{ fromJson(needs.matrix.outputs.matrix) }}
30+
name: "${{ matrix.cfg.job_name }} : Ruby ${{ matrix.cfg.ruby }} on ${{ matrix.cfg.os }}"
31+
runs-on: ${{ matrix.cfg.os }}
32+
env:
33+
PUPPET_GEM_VERSION: ${{ matrix.cfg.puppet_gem_version }}
34+
steps:
35+
- uses: actions/checkout@v2
36+
- uses: ruby/setup-ruby@v1
37+
with:
38+
ruby-version: ${{ matrix.cfg.ruby }}
39+
bundler-cache: true
40+
- name: Update Ruby Gems
41+
shell: pwsh
42+
# Update rubygems to latest if it's using an old version ( < 3.x)
43+
run: |
44+
if ((& gem -v) -match '^(1|2)\.') {
45+
Write-Host '::group::Upgrade Ruby Gems'
46+
gem update --system
47+
Write-Host '::endgroup'
48+
} else {
49+
Write-Host "No need to update rubygems"
50+
}
51+
- name: Test environment information
52+
shell: pwsh
53+
run: |
54+
Write-Host '--- Ruby version'
55+
& ruby -v
56+
Write-Host '--- Gem version'
57+
& gem -v
58+
Write-Host '--- Bundler version'
59+
& bundle -v
60+
Write-Host '--- Gem lock file contents'
61+
Get-Content Gemfile.lock -Raw
62+
Write-Host '--- Puppet version'
63+
& bundle exec puppet --version
64+
- name: Run rake ${{ matrix.cfg.rake_tasks }}
65+
# To enable debug messages for the Acceptance Tests
66+
# env:
67+
# SPEC_DEBUG: 'true'
68+
run: bundle exec rake ${{ matrix.cfg.rake_tasks }}
69+
70+
build:
71+
needs: [run-tests]
72+
name: "Build Editor Service"
73+
runs-on: ubuntu-latest
74+
steps:
75+
- uses: actions/checkout@v2
76+
- uses: ruby/setup-ruby@v1
77+
with:
78+
ruby-version: '2.7'
79+
bundler-cache: true
80+
- name: Set build version
81+
shell: pwsh
82+
run: |
83+
'99.99.0-gh.${{ github.run_number }}' | Out-File -FilePath 'lib\puppet_editor_services\VERSION' -Encoding ASCII -Confirm:$false -Force
84+
- name: Run rake gem_revendor build
85+
run: bundle exec rake gem_revendor build
86+
- name: 'Upload Artifact'
87+
uses: actions/upload-artifact@v2
88+
with:
89+
name: puppet-editor-services
90+
path: output/*.zip
91+
retention-days: 2

.travis.yml

Lines changed: 0 additions & 70 deletions
This file was deleted.

appveyor.yml

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)