From ebfc109fda5addd5e937641aaf4fa6b1527281c9 Mon Sep 17 00:00:00 2001 From: dosas Date: Tue, 20 Feb 2024 15:13:12 +0100 Subject: [PATCH] Use theforeman github actions for ruby testing --- .github/workflows/rubocop.yaml | 22 --------- .github/workflows/ruby_tests.yml | 27 +++++++++++ .github/workflows/unit_tests.yaml | 78 ------------------------------- 3 files changed, 27 insertions(+), 100 deletions(-) delete mode 100644 .github/workflows/rubocop.yaml create mode 100644 .github/workflows/ruby_tests.yml delete mode 100644 .github/workflows/unit_tests.yaml diff --git a/.github/workflows/rubocop.yaml b/.github/workflows/rubocop.yaml deleted file mode 100644 index 6b5b7d36..00000000 --- a/.github/workflows/rubocop.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: Rubocop -on: - pull_request: - push: - branches: - - master -jobs: - rubocop: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - run: sudo apt-get update - - run: sudo apt-get install libyaml-dev - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.7 - - run: | - gem install theforeman-rubocop -v 0.1.0 - - name: Execute rubocop - run: | - rubocop diff --git a/.github/workflows/ruby_tests.yml b/.github/workflows/ruby_tests.yml new file mode 100644 index 00000000..e1c22300 --- /dev/null +++ b/.github/workflows/ruby_tests.yml @@ -0,0 +1,27 @@ +--- +name: Ruby Tests +"on": + push: + branches: + - main + pull_request: + +concurrency: + group: ${{ github.ref_name }}-${{ github.workflow }} + cancel-in-progress: true + +jobs: + rubocop: + uses: theforeman/actions/.github/workflows/rubocop.yml@v0 + with: + command: bundle exec rubocop --parallel + + test: + name: Ruby + needs: rubocop + uses: theforeman/actions/.github/workflows/foreman_plugin.yml@v0 + with: + plugin: foreman_scc_manager + matrix_exclude: '[{"ruby": "3.0", "node": "14"}]' + postgresql_container: ghcr.io/theforeman/postgresql-evr + test_existing_database: false diff --git a/.github/workflows/unit_tests.yaml b/.github/workflows/unit_tests.yaml deleted file mode 100644 index 6a74a025..00000000 --- a/.github/workflows/unit_tests.yaml +++ /dev/null @@ -1,78 +0,0 @@ -name: Unit tests -on: - push: - branches: - - master - pull_request: - -defaults: - run: - working-directory: /projects/foreman - -jobs: - test_ruby: - defaults: - run: - working-directory: /projects/foreman - env: - PGHOST: postgres - PGUSER: foreman - PGPASS: foreman - RAILS_ENV: test - host: postgres - WORKDIR: /projects/foreman - BUNDLE_PATH: vendor/bundle - GIT_COMMITTER_NAME: "gh_actions" - GIT_COMMITTER_EMAIL: "gh_actions@rh_cloud.foreman" - strategy: - fail-fast: false - matrix: - image_version: [9.0.55] - - runs-on: ubuntu-latest - container: - image: ghcr.io/theforeman/tfm_plugin_test:${{ matrix.image_version }} - - services: - postgres: - image: quay.io/jomitsch/postgres-with-evr - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - env: - POSTGRES_USER: foreman - POSTGRES_PASSWORD: foreman - - steps: - - name: Checkout foreman_scc_manager repo - uses: actions/checkout@v2 - with: - path: ${{ github.workspace }}/projects/foreman_scc_manager - - name: Fix git config - run: | - cp -Rf $GITHUB_WORKSPACE/projects/foreman_scc_manager /projects/ - cd /projects/foreman - echo "gemspec :path => '../foreman_scc_manager'" > bundler.d/foreman_scc_manager.local.rb - /usr/bin/entrypoint.sh git config --global user.name $GIT_COMMITTER_NAME - /usr/bin/entrypoint.sh git config --global user.email $GIT_COMMITTER_EMAIL - - name: remove foreman_rh_cloud and dependencies - working-directory: /projects/foreman - run: | - rm bundler.d/foreman_rh_cloud.local.rb - rm bundler.d/foreman_remote_execution.local.rb - - name: Run tests suite - run: | - cd /projects/foreman - ls -al /usr/bin - /usr/bin/entrypoint.sh chmod +rx /usr/bin/run_tests.sh - /usr/bin/entrypoint.sh touch /usr/bin/setup_env.sh - /usr/bin/entrypoint.sh chmod +rx /usr/bin/setup_env.sh - /usr/bin/entrypoint.sh head -n -10 /usr/bin/run_tests.sh > /usr/bin/setup_env.sh - /usr/bin/entrypoint.sh /usr/bin/setup_env.sh - - name: Run Scc manager tests - working-directory: /projects/foreman - run: | - /usr/bin/entrypoint.sh bundle exec rake test:foreman_scc_manager - /usr/bin/entrypoint.sh bundle exec rake test TEST="test/unit/foreman/access_permissions_test.rb"