diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fcf3b18..06e6aa9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,49 +6,51 @@ on: branches: [ main ] jobs: - scan_ruby: + build_test: # all steps run in dev container runs-on: ubuntu-latest - steps: - name: Checkout code uses: actions/checkout@v4 - - name: Run brakeman - uses: devcontainers/ci@v0.3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 with: - runCmd: bin/brakeman --no-pager + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} - lint: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 + - name: Build Dev Container task + uses: devcontainers/ci@v0.3 with: - ruby-version: .ruby-version - bundler-cache: true + imageName: ghcr.io/astral-devcontainer + cacheFrom: ghcr.io/astral-devcontainer + push: never + runCmd: | + # Add multiple commands to run if needed + bundle install - name: Lint code for consistent style - run: bin/rubocop -f github - - test: - runs-on: ubuntu-latest - - # services: - # redis: - # image: redis - # ports: - # - 6379:6379 - # options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 - steps: - - name: Checkout code - uses: actions/checkout@v4 + uses: devcontainers/ci@v0.3 + with: + imageName: ghcr.io/astral-devcontainer + cacheFrom: ghcr.io/astral-devcontainer + push: never + runCmd: bin/rubocop -f github + + - name: Run brakeman + uses: devcontainers/ci@v0.3 + with: + imageName: ghcr.io/astral-devcontainer + cacheFrom: ghcr.io/astral-devcontainer + push: never + runCmd: bin/brakeman --no-pager - name: Run tests uses: devcontainers/ci@v0.3 with: + imageName: ghcr.io/astral-devcontainer + cacheFrom: ghcr.io/astral-devcontainer + push: never runCmd: bin/rails test - name: Keep screenshots from failed system tests diff --git a/README.md b/README.md index 335d513..03ab0fa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # README -Astral-rails is a proof-of-concept api application intended to simplify +Astral is an api-only application intended to simplify certificate acquisition for other applications/services. Broadly speaking, it will: @@ -10,18 +10,21 @@ it will: # Running -This app is most easily run and developed in its devcontainer. +This Rails app is most easily run and developed in its devcontainer. 1) Open in devcontainer 2) Launch server using vscode launch config, or in terminal run: ``` rails s ``` -3) POST /certificates to acquire cert in terminal: +3) POST /certificates to acquire cert in another terminal (need to provide `common_name` param): ``` curl -X POST http://localhost:3000/certificates \ -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqb2huLmRvZUBleGFtcGxlLmNvbSIsIm5hbWUiOiJKb2huIERvZSIsImlhdCI6MTUxNjIzOTAyMiwiZ3JvdXBzIjpbImdyb3VwMSIsImdyb3VwMiJdLCJhdWQiOiJhc3RyYWwifQ.tfRLXmE_eq-piP88_clwPWrYfMAQbCJAeZQI6OFxZSI" \ -H "Content-type: application/json" \ -d "{ \"common_name\": \"example.com\" }" ``` - +4) Run the tests from devcontainer terminal: +``` +rails test +``` diff --git a/test/interactors/obtain_cert_test.rb b/test/interactors/obtain_cert_test.rb index e423811..3211ae2 100644 --- a/test/interactors/obtain_cert_test.rb +++ b/test/interactors/obtain_cert_test.rb @@ -24,7 +24,7 @@ def setup Services::CertificateService.stub :new, srv do context = @interactor.call(request: request) assert context.failure? - assert_equal nil, context.cert + assert_nil context.cert end end end