Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI/CD Fix unit test workflow #441

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
89d0f35
Temporarily disable failing unit tests
Splines Mar 30, 2023
924f11d
Improve unit test workflow file
Splines Mar 31, 2023
ed93616
Ignore buildable images on docker compose pull
Splines Mar 31, 2023
5625d77
Revert "Temporarily disable failing unit tests"
Splines Apr 10, 2023
9f2e768
Fix failing unit tests by precompiling assets
Splines Apr 10, 2023
87d6ed6
Run docker commands in new containers
Splines Apr 11, 2023
0919f81
Fix infinite GitHub actions running
Splines Apr 11, 2023
eeaf5c8
Try to change order of rake tasks
Splines Apr 11, 2023
4a00816
Try splitting rake tasks into two separate commands
Splines Apr 11, 2023
ed7cefb
Fix wrong indentation
Splines Apr 11, 2023
986842b
Run yarn install before assets:precompile
Splines Apr 11, 2023
5e158c5
Try out pipeline without docker caching
Splines Apr 11, 2023
7c16b1d
Add webpacker as dev dependency
Splines Apr 11, 2023
59a3383
Let workflow timeout after 20min
Splines Apr 11, 2023
3eaa756
Install frontend dev dependencies in docker
Splines Apr 11, 2023
dd16925
Remove unnecessary dev dependencies
Splines Apr 11, 2023
6628197
Remove unneeded packages in yarn lock
Splines Apr 11, 2023
1cd37f9
Use docker compose file under run_tests folder
Splines Apr 18, 2023
380df26
Try using rails CLI instead of rake
Splines Apr 18, 2023
bbd305a
Revert to rake CLI
Splines Apr 18, 2023
4927cca
Comment out entry point
Splines Apr 18, 2023
bbeb840
Revert dev Dockerfile yarn installation
Splines Apr 18, 2023
9e07799
Explicitly install webpacker
Splines Apr 18, 2023
f55f848
Install yarn packages with docker for tests
Splines Apr 19, 2023
74fe6cc
Remove rake webpacker:install
Splines Apr 19, 2023
1152257
Explicitly use "yarn install" in Dockerfile
Splines Apr 19, 2023
d892237
Try again to also install webpacker via rake
Splines Apr 19, 2023
dfb1a61
Upgrade Node to v20 for unit tests
Splines Apr 21, 2023
bf4c13c
Remove explicit "yarn install" in Dockerfile
Splines Apr 21, 2023
fc9fcd7
Run "bundle exec rails webpacker:install" in dockerfile
Splines Apr 21, 2023
5543196
Use webpacker:compile in dockerfile
Splines Apr 21, 2023
db541f0
Add yarn install before webpack install/compile
Splines Apr 21, 2023
f395931
Use Node v18
Splines Apr 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions .github/workflows/codecov.yml

This file was deleted.

51 changes: 51 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Unit tests

on:
push:
branches:
- main
- mampf-next
- production
- experimental
pull_request:

jobs:
unit-test-job:
name: Execute unit tests & upload to Codecov
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive

- name: Pull docker images
run: docker compose pull --ignore-buildable
working-directory: docker/run_tests

- name: Build docker containers
working-directory: docker/run_tests
run: docker compose build

- name: Create and prepare test database
working-directory: docker/run_tests
run: docker compose run --entrypoint="" mampf
sh -c "RAILS_ENV=test rails db:create db:migrate db:test:prepare"

- name: Prepare for test execution
working-directory: docker/run_tests
run: docker compose run --entrypoint="" mampf
sh -c "RAILS_ENV=test rake webpacker:install assets:precompile sunspot:reindex"

- name: Run unit tests
working-directory: docker/run_tests
run: docker compose run --entrypoint="" mampf
sh -c "RAILS_ENV=test rails spec"

- name: Send test coverage report to Codecov
uses: codecov/codecov-action@v3
with:
directory: ./coverage
fail_ci_if_error: true
verbose: true
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ gem "puma", "~> 4.1"
# Use SCSS for stylesheets
gem "sass-rails", ">= 6"
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
# gem 'webpacker', '~> 4.0'
gem 'webpacker', '~> 5.x'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem "turbolinks", "~> 5"
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
Expand Down Expand Up @@ -104,7 +104,6 @@ gem "premailer-rails"
gem "clipboard-rails"
gem "rubyzip", "~> 2.3.0"
gem "exception_handler", "~> 0.8.0.0"
gem 'webpacker', '~> 5.x'
gem 'net-smtp'

group :development, :docker_development, :test do
Expand Down
8 changes: 5 additions & 3 deletions docker/run_tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ EXPOSE 3000
ENTRYPOINT ["/usr/src/app/entrypoint.sh"]

# https://github.com/nodesource/distributions#installation-instructions
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get install -y nodejs yarn ffmpeg imagemagick pdftk ghostscript sqlite3 shared-mime-info --no-install-recommends && rm -rf /var/lib/apt/lists/* && apt-get clean

RUN groupadd -g 501 app && useradd -g 501 -u 501 -m -d /usr/src/app app
WORKDIR /usr/src/app
USER app

COPY --chown=app:app ./Gemfile ./Gemfile.lock /usr/src/app/
RUN bundle install
COPY --chown=app:app ./Gemfile ./Gemfile.lock ./yarn.lock ./package.json /usr/src/app/
RUN bundle install && yarn install --production=false
RUN bundle exec rails webpacker:install webpacker:compile

COPY --chown=app:app ./ /usr/src/app/
2 changes: 1 addition & 1 deletion docker/run_tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ services:
dockerfile: docker/run_tests/Dockerfile
image: mampf:tests
container_name: mampf_mampf_test
entrypoint: ./docker/run_tests/run_tests.sh
# entrypoint: ./docker/run_tests/run_tests.sh
environment:
RAILS_ENV: test
TEST_DATABASE_ADAPTER: postgresql
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,5 @@
},
"scripts": {
"lint": "eslint ."
},
"devDependencies": {
"cypress": "9.5.1"
}
}
}
Loading