From 3996f0e94d80f10a81ab47db106cf0e59e404fc5 Mon Sep 17 00:00:00 2001 From: Thomas Hareau Date: Fri, 18 Sep 2020 11:46:27 +0200 Subject: [PATCH] Add github action (#17) * Add github action * Remove travis * Add only rubocop * Setup CI: using local actions (#3) * Using local actions * Add RuboCop * Limit to push master and pr * Pull request only * No dependency on test * Using real ruby versions * Update ruby version * options for PG? * Start service * Split * Change service * with env * Remove host * Stop starting the service * Trying other config * idea * Adding password to env * real test script * Add cache * Add rubocop * Install in dedicated script * Fix * Fix fix * Fix fix fix * remove needs * Using doctolib actions * Using 9.6 --- .../continuous-integration-workflow.yml | 72 +++++++++++++++++++ .travis.yml | 11 --- 2 files changed, 72 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/continuous-integration-workflow.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml new file mode 100644 index 0000000..d84ffeb --- /dev/null +++ b/.github/workflows/continuous-integration-workflow.yml @@ -0,0 +1,72 @@ +env: + RUBY_VERSION: 2.6.x + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: safe_pg_migrations_test + PGPASSWORD: postgres + +name: Rake tests +on: pull_request + +jobs: + rubocop-test: + name: Rubocop + runs-on: ubuntu-18.04 + steps: + - uses: doctolib/checkout@v1 + - uses: doctolib/setup-ruby@v1 + with: + ruby-version: ${{ env.RUBY_VERSION }} + - uses: doctolib/cache@v2 + with: + path: vendor/bundle + key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gems- + - name: bundle + run: | + gem install bundler + bundle config path vendor/bundle + bundle install --jobs 4 --retry 3 + - name: Install Rubocop + run: gem install rubocop + - name: Check code + run: bundle exec rubocop + unit-test: + name: UnitTest + runs-on: ubuntu-18.04 + # Service containers to run with `container-job` + services: + postgres: + image: postgres:9.6 + env: + POSTGRES_DB: safe_pg_migrations_test + POSTGRES_PASSWORD: postgres + POSTGRES_USER: postgres + ports: + - 5432:5432 + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: + - uses: doctolib/checkout@v1 + - name: Set up Ruby + uses: doctolib/setup-ruby@v1 + with: + ruby-version: ${{ env.RUBY_VERSION }} + - uses: doctolib/cache@v2 + with: + path: vendor/bundle + key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gems- + - name: bundle + run: | + gem install bundler + bundle config path vendor/bundle + bundle install --jobs 4 --retry 3 + - name: Run tests + run: bundle exec rake test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4028606..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: ruby -cache: bundler -rvm: - - 2.5 -services: - - postgresql -addons: - postgresql: "9.6" - -before_script: - - psql -c 'CREATE DATABASE safe_pg_migrations_test' -U postgres