generated from dxw/rails-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2424 from UKGovernmentBEIS/chore/update-ci
Update CI
- Loading branch information
Showing
12 changed files
with
115 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Build and cache | ||
description: | | ||
Builds the Docker image, caches layers to the Github action cache | ||
and loads the built image into Docker" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- | ||
name: Build and cache | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
build-args: | | ||
RAILS_ENV=test | ||
push: false | ||
load: true | ||
tags: app_test:latest | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=min |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: CI Checks | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
lint-and-format: | ||
name: Linting and formatting | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v4 | ||
- | ||
name: Build and cache | ||
uses: ./.github/workflows/build_and_cache | ||
- | ||
name: Run Standard Ruby | ||
run: | | ||
docker run --rm app_test:latest /bin/bash -c "bundle exec standardrb -f simple" | ||
- | ||
name: Run Shellcheck | ||
run: | | ||
for file in $(git ls-files script/*) | ||
do shellcheck -x "$file" | ||
done | ||
static-analysis: | ||
name: Static analysis | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v4 | ||
- | ||
name: Build and cache | ||
uses: ./.github/workflows/build_and_cache | ||
- | ||
name: Run Brakeman | ||
run: | | ||
docker run --rm app_test:latest /bin/bash -c "bundle exec brakeman -o /dev/stdout" | ||
specs: | ||
name: Specs and coverage | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v4 | ||
- | ||
name: Build and cache | ||
uses: ./.github/workflows/build_and_cache | ||
- | ||
name: Run Rspec and Simplebcov | ||
run: | | ||
docker compose -p app_test -f docker-compose.ci.yml \ | ||
run --name app_test test /bin/bash -c "bin/rspec --format=documentation" | ||
- | ||
name: Shutdown containers | ||
run: docker compose -p app_test down && docker compose -p app_test rm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,16 @@ | |
# base | ||
# ------------------------------------------------------------------------------ | ||
FROM ruby:3.1.2 AS base | ||
MAINTAINER dxw <[email protected]> | ||
|
||
ARG RAILS_ENV | ||
ARG NODE_MAJOR | ||
|
||
ENV APP_HOME /app | ||
ENV DEPS_HOME /deps | ||
ENV APP_HOME=/app | ||
ENV DEPS_HOME=/deps | ||
|
||
ENV NODE_MAJOR ${NODE_MAJOR:-16} | ||
ENV RAILS_ENV ${RAILS_ENV:-production} | ||
ENV NODE_ENV ${RAILS_ENV:-production} | ||
ENV NODE_MAJOR=${NODE_MAJOR:-16} | ||
ENV RAILS_ENV=${RAILS_ENV:-production} | ||
ENV NODE_ENV=${RAILS_ENV:-production} | ||
|
||
# Setup Node installation | ||
# https://github.com/nodesource/distributions#installation-instructions | ||
|
@@ -40,6 +39,23 @@ RUN apt-get update && apt-get install -qq -y \ | |
yarn \ | ||
--fix-missing --no-install-recommends | ||
|
||
# Install Firefox and Gecko driver if RAILS_ENV=test | ||
RUN \ | ||
if [ "${RAILS_ENV}" = "test" ]; then \ | ||
apt-get install -qq -y --fix-missing firefox-esr shellcheck; \ | ||
fi | ||
|
||
ARG gecko_driver_version=0.31.0 | ||
|
||
RUN \ | ||
if [ "${RAILS_ENV}" = "test" ]; then \ | ||
wget https://github.com/mozilla/geckodriver/releases/download/v$gecko_driver_version/geckodriver-v$gecko_driver_version-linux64.tar.gz && \ | ||
tar -xvzf geckodriver-v$gecko_driver_version-linux64.tar.gz && \ | ||
rm geckodriver-v$gecko_driver_version-linux64.tar.gz && \ | ||
chmod +x geckodriver && \ | ||
mv geckodriver* /usr/local/bin; \ | ||
fi | ||
|
||
RUN echo "\nexport PATH=/usr/local/bin:\$PATH\n\n# Stop here if non-interactive shell\n[[ \$- == *i* ]] || return\n\ncd /app" >> ~/.bashrc | ||
|
||
# ------------------------------------------------------------------------------ | ||
|
@@ -124,19 +140,3 @@ ENTRYPOINT ["/docker-entrypoint.sh"] | |
EXPOSE 3000 | ||
|
||
CMD ["bundle", "exec", "puma"] | ||
|
||
# ------------------------------------------------------------------------------ | ||
# test | ||
# ------------------------------------------------------------------------------ | ||
FROM web as test | ||
|
||
RUN apt-get install -qq -y --fix-missing firefox-esr \ | ||
shellcheck | ||
|
||
ARG gecko_driver_version=0.31.0 | ||
|
||
RUN wget https://github.com/mozilla/geckodriver/releases/download/v$gecko_driver_version/geckodriver-v$gecko_driver_version-linux64.tar.gz | ||
RUN tar -xvzf geckodriver-v$gecko_driver_version-linux64.tar.gz | ||
RUN rm geckodriver-v$gecko_driver_version-linux64.tar.gz | ||
RUN chmod +x geckodriver | ||
RUN mv geckodriver* /usr/local/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters