Skip to content

Commit

Permalink
Switch from Travis CI to GitHub Actions (#13)
Browse files Browse the repository at this point in the history
https://eaflood.atlassian.net/browse/RUBY-1229

We have decided to switch from Travis CI to GitHub Actions. This PR updates our config and readme.

* Fix linter issue
  • Loading branch information
irisfaraway committed Dec 18, 2020
1 parent 8f0fd1e commit e650a2d
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 26 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI

on: push

jobs:
build:
# You must use a Linux environment when using service containers or container jobs
runs-on: ubuntu-latest

steps:
# Downloads a copy of the code in your repository before running CI tests
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of sonarcloud analysis

# We don't have to specify the ruby version, or grab it from .ruby-verion. This action supports reading the
# version from .ruby-verion itself
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true # runs 'bundle install' and caches installed gems automatically

# Run linting first. No point running the tests if there is a linting issue
- name: Run lint check
run: |
bundle exec rubocop --format progress --format json --out rubocop-result.json
# This includes an extra run step. The sonarcloud analysis will be run in a docker container with the current
# folder mounted as `/github/workspace`. The problem is when the .resultset.json file is generated it will
# reference the code in the current folder. So to enable sonarcloud to matchup code coverage with the files we use
# sed to update the references in .resultset.json
# https://community.sonarsource.com/t/code-coverage-doesnt-work-with-github-action/16747/6
- name: Run unit tests
run: |
bundle exec rspec
sed -i 's/\/home\/runner\/work\/defra-ruby-alert\/defra-ruby-alert\//\/github\/workspace\//g' coverage/.resultset.json
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This is provided automatically by GitHub
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # This needs to be set in your repo; settings -> secrets
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Defra Ruby Alert

[![Build Status](https://travis-ci.com/DEFRA/defra-ruby-alert.svg?branch=main)](https://travis-ci.com/DEFRA/defra-ruby-alert)
![Build Status](https://github.com/DEFRA/defra-ruby-alert/workflows/CI/badge.svg?branch=main)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=DEFRA_defra-ruby-alert&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=DEFRA_defra-ruby-alert)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=DEFRA_defra-ruby-alert&metric=coverage)](https://sonarcloud.io/dashboard?id=DEFRA_defra-ruby-alert)
[![security](https://hakiri.io/github/DEFRA/defra-ruby-alert/main.svg)](https://hakiri.io/github/DEFRA/defra-ruby-alert/main)
Expand Down
2 changes: 2 additions & 0 deletions defra_ruby_alert.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# rubocop:disable Gemspec/RequiredRubyVersion
# frozen_string_literal: true

$LOAD_PATH.push File.expand_path("lib", __dir__)
Expand Down Expand Up @@ -51,3 +52,4 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "simplecov", "~> 0.17.1"
spec.add_development_dependency "webmock", "~> 3.4"
end
# rubocop:enable Gemspec/RequiredRubyVersion
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sonar.projectVersion=1.0.0

# This will add the same links in the SonarCloud UI
sonar.links.homepage=https://github.com/DEFRA/defra-ruby-alert
sonar.links.ci=https://travis-ci.com/DEFRA/defra-ruby-alert
sonar.links.ci=https://github.com/DEFRA/defra-ruby-alert/actions
sonar.links.scm=https://github.com/DEFRA/defra-ruby-alert
sonar.links.issue=https://github.com/DEFRA/ruby-services-team/issues

Expand Down

0 comments on commit e650a2d

Please sign in to comment.