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

Use docker compose for github actions #101

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
REVERSER_DATA_PATH=
# Change the ports that are forwarded by docker to avoid potential conflicts
EXPOSED_SERVER_PORT=9000
EXPOSED_POSTGRES_PORT=34518
EXPOSED_VNC_PORT=7900
# EXPOSED_SERVER_PORT=
# EXPOSED_POSTGRES_PORT=
# EXPOSED_VNC_PORT=
# Uncomment if you want to do development with vscode+solargraph
# COMPOSE_PROFILES=solargraph
2 changes: 1 addition & 1 deletion .github/prepare-docker-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ runs:
tags: reverser:test

- name: Set docker run command
run: echo "DOCKER_RUN=docker run --rm --network host -e POSTGRES_HOST=localhost -e EXPOSED_VNC_PORT=123 -e RAILS_ENV=test -e CI=true -v $PWD:/app reverser:test" >> "$GITHUB_ENV"
run: echo "DOCKER_RUN=docker compose run --rm -e REVERSER_DATA_PATH=dummy -e CI=true" >> "$GITHUB_ENV"
shell: bash
23 changes: 2 additions & 21 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,12 @@ jobs:
runs-on: ubuntu-latest
needs: docker-build

services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_USER: reverser
POSTGRES_DB: reverser_test
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- 5432:5432
options: >-
--mount type=tmpfs,destination=/var/lib/postgresql/data
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v4
- uses: ./.github/prepare-docker-image

- name: Create DB
run: $DOCKER_RUN bin/rails db:schema:load

- name: Run Tests
run: $DOCKER_RUN bundle exec rails test
run: docker compose run --rm -e REVERSER_DATA_PATH=dummy -e CI=true tests

rubocop:
runs-on: ubuntu-latest
Expand All @@ -65,7 +46,7 @@ jobs:
- uses: ./.github/prepare-docker-image

- name: Run Rubocop
run: $DOCKER_RUN bundle exec rubocop --format github
run: $DOCKER_RUN rubocop --format github

yamllint:
runs-on: ubuntu-latest
Expand Down
17 changes: 10 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
version: "3"

x-environment: &common-env
EXPOSED_VNC_PORT: ${EXPOSED_VNC_PORT:-7900}
IQDB_URL: ${IQDB_URL:-http://iqdb:5588}
SELENIUM_URL: ${SELENIUM_URL:-http://selenium:4444}

services:
reverser:
build:
Expand All @@ -8,9 +13,7 @@ services:
COMPOSE_PROFILES: ${COMPOSE_PROFILES-}
image: reverser
environment:
EXPOSED_VNC_PORT: ${EXPOSED_VNC_PORT:?}
IQDB_URL: ${IQDB_URL:-http://iqdb:5588}
SELENIUM_URL: ${SELENIUM_URL:-http://selenium:4444}
<<: *common-env
volumes:
- .:/app
- build_assets:/app/public/build
Expand All @@ -27,7 +30,7 @@ services:
- iqdb
- selenium
ports:
- ${EXPOSED_SERVER_PORT:?}:9000
- ${EXPOSED_SERVER_PORT:-9000}:9000
command: foreman start --color

solargraph:
Expand All @@ -51,7 +54,7 @@ services:
- ${REVERSER_DATA_PATH:?}/db_data:/var/lib/postgresql/data
shm_size: 256mb
ports:
- ${EXPOSED_POSTGRES_PORT:?}:5432
- ${EXPOSED_POSTGRES_PORT:-34518}:5432

iqdb:
image: ghcr.io/e621ng/iqdb:d4fed9d9a51184e72d2f14d4ec461d7830bd177a
Expand All @@ -64,7 +67,7 @@ services:
- VNC_NO_PASSWORD=1
shm_size: 2gb
ports:
- ${EXPOSED_VNC_PORT:?}:7900
- ${EXPOSED_VNC_PORT:-7900}:7900

# Profiles for standalone things

Expand All @@ -80,7 +83,7 @@ services:
tests:
image: reverser
environment:
EXPOSED_VNC_PORT: "123"
<<: *common-env
volumes:
- .:/app
entrypoint: bundle exec rails test
Expand Down