Skip to content

Commit

Permalink
Merge pull request #4 from G-Research/ci-tweak
Browse files Browse the repository at this point in the history
added container persistence for dev container; plus readme tweaks
  • Loading branch information
dave-gantenbein authored Sep 4, 2024
2 parents 88cb203 + 8cb1d03 commit aed50a1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 34 deletions.
60 changes: 31 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
- 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/[email protected]
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/[email protected]
with:
imageName: ghcr.io/astral-devcontainer
cacheFrom: ghcr.io/astral-devcontainer
push: never
runCmd: bin/rubocop -f github

- name: Run brakeman
uses: devcontainers/[email protected]
with:
imageName: ghcr.io/astral-devcontainer
cacheFrom: ghcr.io/astral-devcontainer
push: never
runCmd: bin/brakeman --no-pager

- name: Run tests
uses: devcontainers/[email protected]
with:
imageName: ghcr.io/astral-devcontainer
cacheFrom: ghcr.io/astral-devcontainer
push: never
runCmd: bin/rails test

- name: Keep screenshots from failed system tests
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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:

Expand All @@ -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
```
2 changes: 1 addition & 1 deletion test/interactors/obtain_cert_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit aed50a1

Please sign in to comment.