From d6c66637f79684172ff94b154caa385df021f462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yannik=20D=C3=A4llenbach?= Date: Mon, 25 Sep 2023 16:37:31 +0200 Subject: [PATCH] CI: Update Workflows (#196) * Format GitHub Actions workflows with Prettier * Use "ruby/setup-ruby@v1" as suggested by authors * Use at least Ruby 2.7 * Update actions/checkout to v4 * Use reviewdog action * Remove unused env "ImageOs" --- .github/workflows/code-style-review.yaml | 85 ++++++++++-------------- .github/workflows/rails-tests.yaml | 74 ++++++++++----------- 2 files changed, 72 insertions(+), 87 deletions(-) diff --git a/.github/workflows/code-style-review.yaml b/.github/workflows/code-style-review.yaml index 0f7b8ce6c..f21efaf68 100644 --- a/.github/workflows/code-style-review.yaml +++ b/.github/workflows/code-style-review.yaml @@ -1,59 +1,46 @@ -name: 'Code Style Review' +name: "Code Style Review" on: pull_request: branches: - - 'master' + - "master" paths-ignore: - - 'doc/**' - - '**.md' + - "doc/**" + - "**.md" jobs: lint: - runs-on: 'ubuntu-latest' + runs-on: "ubuntu-latest" steps: - - name: 'Checkout' - uses: actions/checkout@v2 - - - name: 'Set up Ruby' - uses: actions/setup-ruby@v1 - with: - ruby-version: '2.6' - - - name: 'Set up Reviewdog' - env: - REVIEWDOG_INSTALLER: 'https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh' - run: | - mkdir -p $HOME/bin - curl -sfL ${REVIEWDOG_INSTALLER} | sh -s -- -b $HOME/bin - - - name: 'Set up Rubocop' - run: 'gem install rubocop rubocop-minitest rubocop-performance rubocop-rails' - - - name: 'Run Rubocop' - env: - REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - rubocop | - $HOME/bin/reviewdog \ - -f=rubocop \ - -name="Rubocop" \ - -reporter=github-pr-review \ - -level=error \ - -diff="git diff $DIFF_BRANCH" - - - name: 'Set up Haml-lint' - run: 'gem install haml-lint' - - - name: 'Run Haml-lint' - env: - REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - haml-lint | - $HOME/bin/reviewdog \ - -efm="%f:%l %m" \ - -name="Haml-lint" \ - -reporter=github-pr-review \ - -level=error \ - -diff="git diff $DIFF_BRANCH" + - name: "Checkout" + uses: actions/checkout@v4 + + - name: "Set up Ruby" + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + + - name: "Rubocop" + uses: reviewdog/action-rubocop@v2 + with: + rubocop_version: gemfile + rubocop_extensions: rubocop-minitest:gemfile rubocop-performance:gemfile rubocop-rails:gemfile + reporter: github-pr-review + level: error + + - name: "Install HAML-Lint" + run: "gem install haml-lint" + - name: "Set up reviewdog" + uses: reviewdog/action-setup@v1 + - name: "Run reviewdog HAML-Lint" + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + haml-lint | + reviewdog \ + -efm="%f:%l %m" \ + -name="Haml-lint" \ + -reporter=github-pr-review \ + -level=error \ + -diff="git diff $DIFF_BRANCH" diff --git a/.github/workflows/rails-tests.yaml b/.github/workflows/rails-tests.yaml index 225d949f7..1b4a77710 100644 --- a/.github/workflows/rails-tests.yaml +++ b/.github/workflows/rails-tests.yaml @@ -1,68 +1,66 @@ -name: 'Rails Unit Tests' +name: "Rails Unit Tests" on: push: branches: - - 'master' + - "master" paths-ignore: - - 'doc/**' - - '**.md' + - "doc/**" + - "**.md" pull_request: branches: - - 'master' + - "master" paths-ignore: - - 'doc/**' - - '**.md' + - "doc/**" + - "**.md" jobs: build: - runs-on: 'ubuntu-latest' + runs-on: "ubuntu-latest" timeout-minutes: 15 strategy: matrix: - ruby: [ '2.6', '2.7' ] + ruby: ["2.6", "2.7"] services: postgres: - image: 'postgres:11' + image: "postgres:11" env: - POSTGRES_PASSWORD: 'postgres' - ports: [ '5432:5432' ] + POSTGRES_PASSWORD: "postgres" + ports: ["5432:5432"] options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 10s --health-retries 10 memcached: - image: 'memcached' - ports: [ '11211:11211' ] + image: "memcached" + ports: ["11211:11211"] steps: - - name: 'Checkout' - uses: actions/checkout@v2 + - name: "Checkout" + uses: actions/checkout@v4 - - name: 'Set up Ruby ${{ matrix.ruby }}' - uses: ruby/setup-ruby@v1.59.1 - with: - ruby-version: ${{ matrix.ruby }} - bundler-cache: true - env: - ImageOS: ubuntu18 + - name: "Set up Ruby ${{ matrix.ruby }}" + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true - - name: 'Build and test with Rake' - env: - RAILS_TEST_DB_NAME: 'postgres' - RAILS_TEST_DB_USERNAME: 'postgres' - RAILS_TEST_DB_PASSWORD: 'postgres' - RAILS_ENV: 'test' - CI: 'true' - PGDATESTYLE: German - run: | - sudo apt-get -yqq install libpq-dev - gem install bundler --version '~> 2' - bundle install --jobs 4 --retry 3 - bundle exec rails db:create - bundle exec rails db:migrate - bundle exec rails test + - name: "Build and test with Rake" + env: + RAILS_TEST_DB_NAME: "postgres" + RAILS_TEST_DB_USERNAME: "postgres" + RAILS_TEST_DB_PASSWORD: "postgres" + RAILS_ENV: "test" + CI: "true" + PGDATESTYLE: German + run: | + sudo apt-get -yqq install libpq-dev + gem install bundler --version '~> 2' + bundle install --jobs 4 --retry 3 + bundle exec rails db:create + bundle exec rails db:migrate + bundle exec rails test