Unit Tests & Lint #541
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Unit Tests & Lint" | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
schedule: | |
- cron: '0 4 * * *' | |
permissions: | |
actions: write # Needed for skip-duplicate-jobs job | |
contents: read | |
jobs: | |
# Special job which automatically cancels old runs for the same branch, prevents runs for the | |
# same file set which has already passed, etc. | |
pre_job: | |
name: Skip Duplicate Jobs Pre Job | |
runs-on: ubuntu-latest | |
outputs: | |
should_skip: ${{ steps.skip_check.outputs.should_skip }} | |
steps: | |
- id: skip_check | |
uses: fkirc/skip-duplicate-actions@f11521568414503656a5af807dc3018c012552c4 # v3.4.1 | |
with: | |
cancel_others: 'true' | |
github_token: ${{ github.token }} | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
needs: pre_job | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup jRuby | |
uses: ruby/setup-ruby@904f3fef85a9c80a3750cbe7d5159268fd5caa9f # v1.145.0 | |
with: | |
ruby-version: 'jruby-9.2.9.0' | |
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | |
- name: Run rubocop | |
run: | | |
bundle exec rubocop --lint | |
unit_tests: | |
name: Unit Tests | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
needs: pre_job | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup jRuby | |
uses: ruby/setup-ruby@904f3fef85a9c80a3750cbe7d5159268fd5caa9f # v1.145.0 | |
with: | |
ruby-version: 'jruby-9.2.9.0' | |
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | |
- name: Run rspec in parallel | |
run: | | |
bundle exec rspec | |
confirm_no_vendoring: | |
name: Confirm No Vendoring | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
needs: pre_job | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup jRuby | |
uses: ruby/setup-ruby@904f3fef85a9c80a3750cbe7d5159268fd5caa9f # v1.145.0 | |
with: | |
ruby-version: 'jruby-9.2.9.0' | |
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | |
- name: Build and Unpack Gem | |
run: | | |
gem build logstash-output-scalyr.gemspec | |
# We rename the file so we don't need to hard code version in Dockerfile | |
mv logstash-output-scalyr-*.gem logstash-output-scalyr.gem | |
[ ! -d logstash-output-scalyr ] | |
gem unpack logstash-output-scalyr.gem | |
- name: Confirm no vendor directory was unpacked | |
run: | | |
ls -la logstash-output-scalyr/ | |
[ ! -d logstash-output-scalyr/vendor ] | |
- name: Confirm gem doesn't contain spec/ directory | |
run: | | |
ls -la logstash-output-scalyr/ | |
[ ! -d logstash-output-scalyr/spec/ ] |