diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 000000000..c9bc0de4a --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,36 @@ +name: Docker + +on: + workflow_call: + +jobs: + docker: + name: 'Docker: Build' + runs-on: ubuntu-20.04 + + services: + postgres: + image: postgres:16 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: gmmcalcombr_test + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - uses: actions/checkout@v4 + + - name: Build test image + uses: docker/build-push-action@v2 + with: + push: false + context: . + target: test + tags: "gmmcal:test" + + - name: Upload image + uses: ishworkh/container-image-artifact-upload@v1.0.0 + with: + image: "gmmcal:test" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7e7ecc82e..76810086f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,30 +4,23 @@ on: - pull_request jobs: + build: + uses: gmmcal/gmmcal.com.br/.github/workflows/docker.yml@actions + rubocop: name: 'Lint: Rubocop' runs-on: ubuntu-20.04 - - container: - image: ruby:3.2.2 + needs: build steps: - - uses: actions/checkout@v4 - - - uses: actions/cache@v3 + - name: Download an image + uses: ishworkh/container-image-artifact-download@v1.0.0 with: - path: vendor/bundle - key: ${{ runner.os }}-gems-gmmcal-${{ hashFiles('/Gemfile.lock') }} - restore-keys: | - ${{ runner.os }}-gems-gmmcal- - - - name: Run bundle install - run: | - bundle config path vendor/bundle - bundle install --jobs 4 --retry 3 + image: "gmmcal:test" - name: Run rubocop - run: bundle exec rubocop --config .rubocop.yml . + run: | + docker run --rm gmmcal:test bundle exec rubocop --config .rubocop.yml . reek: name: 'Lint: Reek' diff --git a/.gitignore b/.gitignore index 2a4a0c134..4fabfa40a 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ capybara-*.html /public/assets /public/uploads /coverage/ +!/coverage/.keep /spec/tmp /spec/backend/examples.txt /spec/end-to-end/screenshots diff --git a/bin/docker-entrypoint b/bin/docker-entrypoint index 39f5b2bef..a07a6bf17 100755 --- a/bin/docker-entrypoint +++ b/bin/docker-entrypoint @@ -6,4 +6,9 @@ if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then ./bin/rails db:seed:all fi +# bundle exec rspec +if [ "${3}" == "rspec" ]; then + ./bin/rails db:migrate +fi + exec "${@}" diff --git a/coverage/.keep b/coverage/.keep new file mode 100644 index 000000000..e69de29bb