Skip to content

Commit

Permalink
Updating CI and shard versions. Fixing new ameba errors (#81)
Browse files Browse the repository at this point in the history
* Updating CI and shard versions. Fixing new ameba errors

* specify the database in the CI

* testing different options for fixing the DB connection issue on CI

* I don't think this is actually using a DB for anything...

* remove all use of connecting to postgres since the specs don't actually need it
  • Loading branch information
jwoertink authored Oct 20, 2024
1 parent e3837d4 commit b640a22
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 46 deletions.
32 changes: 10 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
runs-on: ubuntu-latest
continue-on-error: false
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- uses: crystal-lang/install-crystal@v1
with:
crystal: 1.4.1
crystal: latest
- name: Install shards
run: shards install
- name: Format
Expand All @@ -27,35 +27,23 @@ jobs:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
postgres_version:
- 16
crystal_version:
- 1.4.0
- 1.10.0
- latest
experimental:
- false
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
services:
postgres:
image: postgres:13-alpine
env:
POSTGRES_USER: lucky
POSTGRES_PASSWORD: developer
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: crystal-lang/install-crystal@v1
with:
crystal: ${{matrix.crystal_version}}
- name: Install shards
run: shards install
- name: Setup Database
run: crystal tasks.cr db.setup
env:
DATABASE_URL: postgres://lucky:developer@localhost:5432/authentic_test
run: shards install --skip-postinstall --skip-executables
- name: Run tests
run: crystal spec
env:
DATABASE_URL: postgres://lucky:developer@localhost:5432/authentic_test
6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: crystal-lang/install-crystal@v1
with:
crystal: latest
- name: "Install shards"
run: shards install
run: shards install --skip-postinstall --skip-executables
- name: "Generate docs"
run: crystal docs
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
14 changes: 2 additions & 12 deletions config.cr
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
database = "authentic_test"

class AppDatabase < Avram::Database
end

# The specs for this shard don't actually make DB queries
AppDatabase.configure do |settings|
if ENV["DATABASE_URL"]?
settings.credentials = Avram::Credentials.parse(ENV["DATABASE_URL"])
else
settings.credentials = Avram::Credentials.new(
database: database,
hostname: "db",
username: "lucky",
password: "developer"
)
end
settings.credentials = Avram::Credentials.parse("postgres://fake:password@localhost:5432/not_used")
end

Avram.configure do |settings|
Expand Down
6 changes: 3 additions & 3 deletions shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 1.0.0
authors:
- Paul Smith <[email protected]>

crystal: ">= 1.6.0"
crystal: ">= 1.10.0"

license: MIT

Expand All @@ -17,9 +17,9 @@ dependencies:
version: ">= 1.0.0"
habitat:
github: luckyframework/habitat
version: ~> 0.4.7
version: ~> 0.4.9

development_dependencies:
ameba:
github: crystal-ameba/ameba
version: ~> 1.1.0
version: ~> 1.5.0
2 changes: 1 addition & 1 deletion spec/action_helpers_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe Authentic::ActionHelpers do
action.sign_in(FakeAuthenticatable.new(id: 123))

action.current_user.should be_a FakeAuthenticatable
action.current_user.not_nil!.id.should eq 123
action.current_user.as(FakeAuthenticatable).id.should eq 123
end

it "returns nil if user is not signed in?" do
Expand Down
2 changes: 1 addition & 1 deletion spec/authentic_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe Authentic do

Authentic.copy_and_encrypt from: password, to: encrypted_password

encrypted_password.value.not_nil!.size.should eq 60
encrypted_password.value.as(String).size.should eq 60
end

it "can create an encrypted password" do
Expand Down
4 changes: 0 additions & 4 deletions spec/spec_helper.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,3 @@ require "spec"
require "../src/authentic"
require "../config"
require "./support/**"

Spec.before_each do
AppDatabase.truncate
end

0 comments on commit b640a22

Please sign in to comment.