From fb37cf8843ce9d402e6deb69bb7611d702a0e5ac Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 4 Aug 2020 16:19:03 +1200 Subject: [PATCH] Adding github actions --- .github/dependabot.yml | 15 +++++++ .github/workflows/ci.yml | 94 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..a1b3e6fd7 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +version: 2 +updates: +- package-ecosystem: npm + directory: "/" + schedule: + interval: daily + time: '17:00' + open-pull-requests-limit: 10 +- package-ecosystem: bundler + directory: "/" + schedule: + interval: daily + time: '17:00' + open-pull-requests-limit: 10 + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..f42987dd4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,94 @@ +name: CI + +on: + pull_request: + push: + branches: + - mainline + - dev + +jobs: + test: + runs-on: ubuntu-latest + services: + db: + image: postgres + env: + ## + # The Postgres service fails its docker health check unless you + # specify these environment variables + # + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: growstuff_test + ports: ['5432:5432'] + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - name: Checkout this repo + uses: actions/checkout@v2 + + ## + # Cache Yarn modules + # + # See https://github.com/actions/cache/blob/master/examples.md#node---yarn for details + # + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + - name: Setup yarn cache + uses: actions/cache@v2 + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install required OS packages + run: | + sudo apt-get -y install libpq-dev google-chrome-stable + + - name: Install NodeJS + uses: actions/setup-node@v2-beta + with: + node-version: '12' + + - name: Install ruby version specified in .ruby-version + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Install JS dependencies + run: yarn install + + - name: Setup codeclimate + run: | + curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + chmod +x ./cc-test-reporter + ./cc-test-reporter before-build + + - name: Prepare database for testing + env: + DATABASE_URL: postgres://postgres:postgres@localhost:5432/growstuff_test + DEVISE_SECRET_KEY: growstuff + RAILS_ENV: test + run: | + bundle exec rails db:prepare + + - name: Run rspec (report results to Percy.io and codeclimate) + env: + DATABASE_URL: postgres://postgres:postgres@localhost:5432/growstuff_test + DEVISE_SECRET_KEY: growstuff + growstuff_ONLINE_SECRET_KEY_BASE: growstuff + APP_DOMAIN_NAME: localhost:3000 + APP_PROTOCOL: http + + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + run: | + bundle exec rspec spec + ./cc-test-reporter after-build --exit-code $?