diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4143675f..33fae6fc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,51 +12,45 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@v1 + - name: install bundle + run: | + bundle config set --local force_ruby_platform true + bundle config build.nokogiri --use-system-libraries + bundle config set --local path 'vendor/bundle'; + bundle config set --local jobs 3 + bundle config set --local retry 3 + docker-compose run --rm --no-deps software bundle install --local + - name: Cache Ruby Bundle + uses: actions/cache@v3 with: - ruby-version: 3.1 - bundler-cache: true - linter: + path: | + vendor/bundle + key: bundle-${{ hashFiles('Gemfile.lock') }} + rubocop: needs: setup runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.1 - bundler-cache: true - name: Run linter - run: bundle exec rubocop + run: docker-compose run --rm --no-deps software bundle exec rubocop haml-linter: needs: setup runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.1 - bundler-cache: true - name: Run linter - run: bundle exec haml-lint app/views/ + run: docker-compose run --rm --no-deps software bundle exec haml-lint app/views/ unit: needs: [linter, haml-linter] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.1 - bundler-cache: true - name: Run unit tests - run: bundle exec rake test + run: docker-compose run --rm software bundle exec rake test system: needs: [linter, haml-linter] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.1 - bundler-cache: true - name: Run system tests - run: bundle exec rake test:system + run: docker-compose run --rm software bundle exec rake test:system diff --git a/.gitignore b/.gitignore index 30a29907..77c3e43f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ diff.diff # Bundler config /.bundle +# Local bundle +/vendor/bundle # Static files in public public/111 diff --git a/Dockerfile b/Dockerfile index 1f7100c4..aa61f6e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,18 +10,22 @@ RUN usermod -u $CONTAINER_USERID software # docker would use it's cache for this and the following stages. ADD Gemfile /software/Gemfile ADD Gemfile.lock /software/Gemfile.lock +COPY vendor/cache /software/vendor/cache RUN chown -R software /software USER software WORKDIR /software -# Setup bundler -# We always want to build for our platform instead of using precompiled gems -ENV BUNDLE_FORCE_RUBY_PLATFORM=true -RUN bundle config build.nokogiri --use-system-libraries - -# Refresh our bundle -RUN bundle install --jobs=3 --retry=3 +# Setup our Ruby bundle +# - build for our platform instead of using precompiled gems +# - use system libraries instead of rebuilding them +# - install into vendor/bundle +RUN bundle config set --local force_ruby_platform true; \ + bundle config build.nokogiri --use-system-libraries; \ + bundle config set --local path 'vendor/bundle'; \ + bundle config set --local jobs 3; \ + bundle config set --local retry 3; \ + bundle install --local # Run our command CMD ["rails", "server", "-b", "0.0.0.0"]