diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d8b69ee..5cc0624 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,12 +8,11 @@ on: pull_request: jobs: - build: + test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@v1 with: ruby-version: "3.3" @@ -22,8 +21,32 @@ jobs: - name: Lint run: bundle exec rake standard + integration_test: + runs-on: ubuntu-latest + + needs: test + + strategy: + matrix: + include: + - ruby_version: "3.3" + redmine_branch_name: "master" + + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.3" + bundler-cache: true + - name: Set up test run: bundle exec rake rexer:test:build_integration_test_image + env: + RUBY_VERSION: ${{ matrix.ruby_version }} + REDMINE_BRANCH_NAME: ${{ matrix.redmine_branch_name }} - - name: Run tests - run: bundle exec rake test + - name: Run integration tests + run: bundle exec rake test:integration + env: + RUBY_VERSION: ${{ matrix.ruby_version }} + REDMINE_BRANCH_NAME: ${{ matrix.redmine_branch_name }} diff --git a/Rakefile b/Rakefile index 5336e15..dd99a35 100644 --- a/Rakefile +++ b/Rakefile @@ -2,10 +2,10 @@ require "bundler/gem_tasks" require "rake/testtask" require "standard/rake" -Rake::TestTask.new(:test) do |t| +Rake::TestTask.new("test:integration") do |t| t.libs << "test" t.libs << "lib" - t.test_files = FileList["test/**/*_test.rb"] + t.test_files = FileList["test/integration/**/*_test.rb"] t.warning = false end @@ -15,7 +15,17 @@ namespace :rexer do namespace :test do desc "Build the integration test image" task :build_integration_test_image do - system "docker build -f test/integration/Dockerfile -t rexer-test .", exception: true + ruby_version = ENV["RUBY_VERSION"] || "3.3" + redmine_branch_name = ENV["REDMINE_BRANCH_NAME"] || "master" + + image_tag = "rexer-test:#{ruby_version}-#{redmine_branch_name}" + + system(<<~CMD, exception: true) + docker build -f test/integration/Dockerfile \ + --build-arg RUBY_VERSION=#{ruby_version} \ + --build-arg REDMINE_BRANCH_NAME=#{redmine_branch_name} \ + -t #{image_tag} . + CMD end end end diff --git a/test/integration/Dockerfile b/test/integration/Dockerfile index 5afd142..a926827 100644 --- a/test/integration/Dockerfile +++ b/test/integration/Dockerfile @@ -2,6 +2,8 @@ ARG RUBY_VERSION=3.3 FROM ruby:$RUBY_VERSION +ARG REDMINE_BRANCH_NAME=master + RUN set -eux; \ apt-get update; \ apt-get install -y --no-install-recommends \ @@ -52,7 +54,7 @@ RUN git init && \ # Redmine # WORKDIR /redmine -RUN git clone --depth 1 https://github.com/redmine/redmine.git . +RUN git clone -b $REDMINE_BRANCH_NAME --depth 1 https://github.com/redmine/redmine.git . COPY test/integration/docker/database.yml config/database.yml # Directory for the bundle cache