Skip to content

Commit fa980bd

Browse files
authored
Merge pull request #288 from glennsarti/add-gh-actions
(maint) Use GitHub actions instead of Travis and Appveyor CI
2 parents 95781f6 + 4691727 commit fa980bd

File tree

6 files changed

+158
-142
lines changed

6 files changed

+158
-142
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

.rubocop.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ Style/ConditionalAssignment:
6464
Style/Next:
6565
Enabled: false
6666

67-
# Enforce LF line endings, even when on Windows
67+
# Line endings are just a mess
6868
Layout/EndOfLine:
69-
EnforcedStyle: lf
69+
Enabled: false
7070

7171
# We only alias for monkey patching
7272
Style/Alias:

.travis.yml

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

appveyor.yml

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

spec/languageserver/acceptance/end_to_end_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,10 @@ def path_to_uri(path)
327327
expect(result['result']['dependencies']).not_to be_empty
328328

329329
# Workspace Symbols
330+
# TODO: I really don't like this. But unfortunately the workspace symbol loading is asynchronous so you don't _really_ know what it's available
331+
# We could add another Request or extend puppet/getVersion to emit whether the workspace has been loaded yet. In the meantime just sleep a long
332+
# time and hope it's loaded by then.
333+
sleep(15)
330334
@client.send_data(@client.workspace_symbols_request(@client.next_seq_id, ''))
331335
expect(@client).to receive_message_with_request_id_within_timeout([@client.current_seq_id, 15])
332336
result = @client.data_from_request_seq_id(@client.current_seq_id)

0 commit comments

Comments
 (0)