Skip to content

1706948503

1706948503 #17

Workflow file for this run

name: RSpec and Rubocop
on:
push:
branches:
- main
pull_request:
jobs:
ci:
runs-on: ubuntu-latest
name: RSpec and Rubocop
services:
redis:
image: 'redis:6'
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
env:
REDIS_URL: redis://localhost:6379
steps:
- uses: actions/checkout@v3
- name: setup ruby version and foobara branch and sha1
run: |
foobara_entry=`grep -A2 -m 1 ' remote: foobara$' Gemfile.lock`
regex="revision: ([0-9a-f]+)\s+branch: ([-_[:alnum:]]+)$"
if [[ $foobara_entry =~ $regex ]]; then
foobara_sha1="${BASH_REMATCH[1]}"
foobara_branch="${BASH_REMATCH[2]}"
echo foobara_sha1=$foobara_sha1 >> "$GITHUB_ENV"
echo foobara_branch=$foobara_branch >> "$GITHUB_ENV"
else
echo "$foobara_entry doesn't match $regex" >&2
fi
echo ruby_version=`cat .ruby-version` >> "$GITHUB_ENV"
- name: cache foobara
id: cache-foobara
uses: actions/cache@v3
env:
cache-name: cache-foobara
with:
path: ~/work/resque-connector/foobara
key: ${{ env.cache-name }}-${{ env.foobara_branch }}-${{ env.foobara_sha1 }}
restore-keys: |
${{ env.cache-name }}-${{ env.foobara_branch }}-
${{ env.cache-name }}-
- if: ${{ steps.cache-foobara.outputs.cache-hit != 'true' }}
name: clone or pull foobara
run: |
set -e
cd ..
if [ -d foobara ]; then
echo pulling
cd foobara
ssh-agent sh -c 'echo "${{ secrets.FOOBARA_KEY }}" | ssh-add - &&
git fetch --depth=1 origin $foobara_sha1 &&
if git rev-parse --verify -q $foobara_branch; then
git checkout -q $foobara_branch
git reset --hard $foobara_sha1
else
git branch $foobara_branch $foobara_sha1
git checkout -q $foobara_branch
fi'
else
echo cloning
ssh-agent sh -c 'echo "${{ secrets.FOOBARA_KEY }}" | ssh-add - &&
git clone -b $foobara_branch --depth=1 [email protected]:foobara/foobara.git'
fi
- name: symlink foobara and point bundler at it
run: |
set -e
mkdir -p .bundle
echo -e "---\nBUNDLE_LOCAL__FOOBARA: '/home/runner/work/resque-connector/foobara'" > .bundle/config
mkdir ../../foobara
ln -s ../../resque-connector/foobara ../../foobara/foobara
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.ruby_version }}
bundler-cache: true
- name: Run rspec
run: bundle exec rspec
- name: Run rubocop
run: bundle exec rubocop
- name: Upload coverage directory
if: always()
uses: actions/upload-artifact@v2
with:
name: coverage-report
path: coverage/