From a5507d24ada37cca0c29bb6e674e5d88483e8755 Mon Sep 17 00:00:00 2001 From: Joonas Date: Fri, 5 Apr 2024 15:46:21 +0300 Subject: [PATCH] Update workflow --- .github/actions/module-rspec/action.yml | 52 +++++++++++++++++++++++++ .github/workflows/ci_iframe.yml | 37 ++++++++++++++---- 2 files changed, 82 insertions(+), 7 deletions(-) create mode 100644 .github/actions/module-rspec/action.yml diff --git a/.github/actions/module-rspec/action.yml b/.github/actions/module-rspec/action.yml new file mode 100644 index 0000000..2b52610 --- /dev/null +++ b/.github/actions/module-rspec/action.yml @@ -0,0 +1,52 @@ +name: '[CI] Module rspec' +description: 'Test module with rspec' +inputs: + name: + description: 'Module Name' + required: true + github_token: + description: 'Github token' + required: true + +runs: + using: "composite" + steps: + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - uses: actions/setup-node@v3 + with: + node-version: 16 + - name: Get npm cache directory path + id: npm-cache-dir-path + run: echo "dir=$(npm get cache)-${{ inputs.name }}" >> $GITHUB_OUTPUT + shell: "bash" + - uses: actions/cache@v3 + id: npm-cache + with: + path: ${{ steps.npm-cache-dir-path.outputs.dir }} + key: npm-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + npm- + - run: bundle exec rake test_app + name: Create test app + shell: "bash" + - run: mkdir -p ./spec/decidim_dummy_app/tmp/screenshots + name: Create the screenshots folder + shell: "bash" + - uses: nanasess/setup-chromedriver@v2 + - run: RAILS_ENV=test bundle exec rails assets:precompile + name: Precompile assets + working-directory: ./spec/decidim_dummy_app/ + shell: "bash" + - run: bundle exec rspec + name: RSpec + working-directory: ${{ inputs.name }} + shell: "bash" + - uses: codecov/codecov-action@v3 + - uses: actions/upload-artifact@v3 + if: always() + with: + name: screenshots + path: ./spec/decidim_dummy_app/tmp/screenshots + if-no-files-found: ignore diff --git a/.github/workflows/ci_iframe.yml b/.github/workflows/ci_iframe.yml index 213d4f8..d58471f 100644 --- a/.github/workflows/ci_iframe.yml +++ b/.github/workflows/ci_iframe.yml @@ -7,17 +7,40 @@ on: - release/* pull_request: +env: + CI: "true" + CODECOV: "true" + DECIDIM_MODULE: decidim-module-iframe + concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: - build_app: - name: Build test application - uses: mainio/gha-decidim-module/.github/workflows/build_app.yml@main - secrets: inherit main: - needs: build_app name: Tests - uses: mainio/gha-decidim-module/.github/workflows/ci_rspec.yml@main - secrets: inherit + runs-on: ubuntu-latest + timeout-minutes: 30 + services: + postgres: + image: postgres:11 + ports: ["5432:5432"] + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + POSTGRES_PASSWORD: postgres + env: + DATABASE_USERNAME: postgres + DATABASE_PASSWORD: postgres + DATABASE_HOST: localhost + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + - uses: ./.github/actions/module-rspec + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + name: ${{ env.DECIDIM_MODULE }}