Skip to content

Commit

Permalink
Switch automated tests to Github Actions (#5111)
Browse files Browse the repository at this point in the history
  • Loading branch information
retorquere authored Nov 24, 2020
1 parent 726d0d8 commit d4176ca
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 35 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/merge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Merge to release

on:
push:
branches:
- master
workflow_dispatch:
inputs:
commit_message:
description: Commit message
required: true

jobs:
release:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
steps:
- uses: actions/checkout@v2
if: github.event_name == 'push'
- uses: actions/checkout@v2
if: github.event_name == 'workflow_dispatch'
with:
fetch-depth: 0

- name: Checkout release branch
uses: actions/checkout@v2
with:
ref: 'v1.0.1'
path: './release'

- name: Check for relevant changes
if: github.event_name == 'push'
uses: dorny/paths-filter@v2
id: release
with:
list-files: shell
filters: |
updated:
- added|modified: [ '*.csl', '*.xml' ]
deleted:
- deleted: [ '*.csl', '*.xml' ]
- name: Changed files
if: github.event_name == 'push'
run: |
echo updated: ${{ steps.release.outputs.updated_files }}
echo deleted: ${{ steps.release.outputs.deleted_files }}
- name: Set up Ruby
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (steps.release.outputs.updated == 'true' || steps.release.outputs.deleted == 'true'))
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.1
- name: but use cache to speed that up
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (steps.release.outputs.updated == 'true' || steps.release.outputs.deleted == 'true'))
uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Bundle install
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (steps.release.outputs.updated == 'true' || steps.release.outputs.deleted == 'true'))
run: |
bundle config path vendor/bundle
bundle update sheldon --jobs 4 --retry 3
- name: Populate new branch
run: bundle exec sheldon --token=$GITHUB_TOKEN --verbose --populate release
if: github.event_name == 'workflow_dispatch'

- name: update the timestamps and add the changes
run: bundle exec sheldon --token=$GITHUB_TOKEN --verbose --release release ${{ steps.release.outputs.updated_files }}
if: github.event_name == 'push' && steps.release.outputs.updated == 'true'

- name: delete deleted files
run: cd release && git rm ${{ steps.release.outputs.deleted_files }}
if: github.event_name == 'push' && steps.release.outputs.deleted == 'true'

- uses: stefanzweifel/git-auto-commit-action@v4
with:
repository: 'release'
commit_message: Releasing ${{ steps.release.outputs.updated_files }} ${{ steps.release.outputs.deleted_files }}
if: github.event_name == 'push' && (steps.release.outputs.updated == 'true' || steps.release.outputs.deleted == 'true')

- uses: stefanzweifel/git-auto-commit-action@v4
with:
repository: 'release'
commit_message: ${{ github.event.inputs.commit_message }}
if: github.event_name == 'workflow_dispatch'
61 changes: 61 additions & 0 deletions .github/workflows/sheldon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Pull request feedback

on:
pull_request_target:
types: [ opened, synchronize ]

jobs:
test:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
steps:
- uses: actions/checkout@v2

- name: Check for relevant changes
uses: dorny/paths-filter@v2
id: sheldon
with:
list-files: shell
filters: |
changed:
- '*.csl'
- name: Changed files
run: |
echo changed: ${{ steps.sheldon.outputs.changed_files }}
- name: Set up Ruby
if: steps.sheldon.outputs.changed == 'true'
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.1
- name: but use cache to speed that up
if: steps.sheldon.outputs.changed == 'true'
uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Bundle install
if: steps.sheldon.outputs.changed == 'true'
run: |
bundle config path vendor/bundle
bundle update sheldon --jobs 4 --retry 3
- name: Apply the PR
if: steps.sheldon.outputs.changed == 'true'
run: bundle exec sheldon --token=$GITHUB_TOKEN --apply

- name: Welcome to a new PR
if: github.event.action == 'opened' && steps.sheldon.outputs.changed == 'true'
run: bundle exec sheldon --token=$GITHUB_TOKEN --welcome

- name: See if the styles work
if: steps.sheldon.outputs.changed == 'true'
run: bundle exec rake

- name: report
if: (failure() || success()) && steps.sheldon.outputs.changed == 'true'
run: bundle exec sheldon --token=$GITHUB_TOKEN --report --verbose
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/citation-style-language/Sheldon.git
revision: 7822dbda11e229cbd933f84a3a1cfdbe8e75dfaf
revision: 1962fad73610a3e0b1610e0c24c16669d584196b
specs:
sheldon (1.0.2)
citeproc-ruby
Expand Down
12 changes: 1 addition & 11 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,10 @@ rescue Bundler::BundlerError => e
exit e.status_code
end

if ENV['TRAVIS']
at_exit do
system('bundle exec sheldon')
end
end

require 'rspec/core'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|
if ENV['TRAVIS']
spec.rspec_opts = %w{ --require spec_helper.rb --format Fuubar --color --format json --out spec/sheldon/travis.json }
else
spec.rspec_opts = %w{ --require spec_helper.rb --format Fuubar --color --format json --out spec/sheldon/travis.json }
end
spec.rspec_opts = %w{ --require spec_helper.rb --format Fuubar --color --format json --out spec/sheldon/ci.json }
end

task :default => [:spec]

0 comments on commit d4176ca

Please sign in to comment.