-
Notifications
You must be signed in to change notification settings - Fork 6
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
Ruby test and lint github action workflow #161
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,64 @@ | ||
--- | ||
name: "Continuous Integration" | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
pull_request: | ||
types: ['opened', 'reopened', 'synchronize', 'unlocked'] | ||
|
||
jobs: | ||
ruby-lint: | ||
name: Ruby Lint | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1.178.0 | ||
with: | ||
ruby-version: '3.2.3' | ||
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | ||
|
||
- name: Ruby Lint | ||
run: bundle exec standardrb --parallel -f github | ||
|
||
rails-test: | ||
name: Rails Test | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
postgres: | ||
image: postgres:15 | ||
ports: | ||
- "5432:5432" | ||
env: | ||
POSTGRES_DB: sif | ||
POSTGRES_USER: sif | ||
POSTGRES_PASSWORD: password | ||
redis: | ||
image: redis:7.0 | ||
|
||
env: | ||
RAILS_ENV: test | ||
DATABASE_URL: "postgres://sif:password@localhost:5432/sif" | ||
REDIS_URL: "redis://localhost:6379/1" | ||
BROWSERSLIST_IGNORE_OLD_DATA: true | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1.178.0 | ||
with: | ||
ruby-version: '3.2.3' | ||
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | ||
|
||
- name: Set up database | ||
run: bin/rails db:setup | ||
|
||
- name: Run tests | ||
run: bin/rails test |
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,5 @@ | ||
parallel: true | ||
ruby_version: 3.2 | ||
|
||
plugins: | ||
- standard-rails |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this intended? (not too familiar with myself)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think one port is the port inside the container and the other is outside the container (or the other way around)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! This lets the postgres docker image be useable from your host machine.
So if you're comfortable with docker, you could run
docker compose up -d db
from this project directory and have Postgres without having to install it on your OS directly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in docker configuration--ports and volumes in particular--the colon-separated
thing:thing
refers tooutside:inside
orhost:image
.In this case,
5432:5432
read left to right says, "expose on port 5432 on my host machine the port 5432 from inside the docker container".When we use a single value like
5432
, it means "the docker container I'm describing should expose port 5432 to other containers on the same network." "The same network" here means the other services named in docker-compose.yml.