Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d62842f
api client integration tests working
jdettmannnava Mar 4, 2026
5ac64ff
add public key tests
jdettmannnava Mar 5, 2026
ebc4709
skip simple cov in integration test
jdettmannnava Mar 5, 2026
e51c6d7
run integration tests in ci
jdettmannnava Mar 5, 2026
704498b
remove other ci tests for quick check
jdettmannnava Mar 5, 2026
85ec33e
fix ci-api-test
jdettmannnava Mar 5, 2026
f3343d9
consolidate dpc-client build
jdettmannnava Mar 5, 2026
84cca84
typo
jdettmannnava Mar 5, 2026
a8ed34e
debug attribution not starting
jdettmannnava Mar 5, 2026
4b8406c
force debug
jdettmannnava Mar 5, 2026
1104b36
explicitly turn off jacoco
jdettmannnava Mar 5, 2026
eb616d7
unset report coverage
jdettmannnava Mar 5, 2026
82c4352
allow jacoco to be false
jdettmannnava Mar 5, 2026
16f4a37
now debug api
jdettmannnava Mar 5, 2026
d2262f6
debug
jdettmannnava Mar 5, 2026
455d4a8
try to build with tests
jdettmannnava Mar 5, 2026
a2d3f4c
Merge branch 'main' into jd/api-integration-test
jdettmannnava Mar 5, 2026
0e84b1f
try starting from ci-app
jdettmannnava Mar 5, 2026
2d25c83
set correct profile
jdettmannnava Mar 5, 2026
8bacbf7
add secure envs
jdettmannnava Mar 5, 2026
ef39fa7
change too many things at once and hope
jdettmannnava Mar 5, 2026
9331740
add dpc-client-specific file for docker compose
jdettmannnava Mar 5, 2026
5d3e4d3
typo
jdettmannnava Mar 5, 2026
3628043
Merge branch 'main' into jd/api-integration-test
jdettmannnava Mar 5, 2026
4092bda
clean up test
jdettmannnava Mar 5, 2026
57b17fa
let labels
jdettmannnava Mar 5, 2026
78480c8
cleanup
jdettmannnava Mar 5, 2026
4e78e54
cleanup
jdettmannnava Mar 6, 2026
1945a46
Put back all ci tests
jdettmannnava Mar 6, 2026
27b7fe8
single-line single cmd
jdettmannnava Mar 6, 2026
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
40 changes: 35 additions & 5 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ concurrency:

env:
VAULT_PW: ${{ secrets.VAULT_PW }}
REPORT_COVERAGE: true
DPC_CA_CERT: ${{ secrets.DPC_CA_CERT }}
ENV: "github-ci"

jobs:
build-api:
name: "Build and Test API"
runs-on: codebuild-dpc-app-${{github.run_id}}-${{github.run_attempt}}
env:
REPORT_COVERAGE: true
steps:
- name: Assert Ownership
run: sudo chmod -R 777 .
Expand Down Expand Up @@ -194,8 +195,8 @@ jobs:
if: ${{ always() }}
run: ./scripts/cleanup-docker.sh

build-dpc-client:
name: "Build and Test DPC Client"
build-dpc-api-client:
name: "Build and Test DPC API Client"
runs-on: codebuild-dpc-app-${{github.run_id}}-${{github.run_attempt}}
steps:
- name: Assert Ownership
Expand All @@ -204,9 +205,38 @@ jobs:
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- name: Cleanup Runner
run: ./scripts/cleanup-docker.sh
- name: "DPC Client Build"
- name: Install docker compose manually
run: |
make ci-api-client
mkdir -p /usr/local/lib/docker/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.32.4/docker-compose-linux-x86_64 -o /usr/local/lib/docker/cli-plugins/docker-compose
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to be a problem very shortly when the switch is made for CodeBuild to use arm64 runners (I believe happening this month due to annual pricing contracts). Either this should be updated to use arm64 or aarch64 here or in a ticket dedicated to making sure everything can build on arm64.

chown root:root /usr/local/lib/docker/cli-plugins/docker-compose
chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
- name: "API Client Unit Tests"
run: make ci-api-client
- name: "Set up Python and install Ansible"
run: |
sudo dnf -y install python3 python3-pip
pip install ansible
- name: "Set up JDK 17"
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
with:
java-version: "17"
distribution: "corretto"
cache: maven
- name: Clean maven
run: mvn -ntp -U clean
- name: "API Client Integration test"
id: integration-test
run: make ci-api-client-integration
- name: "Debug db"
if: ${{ failure() && steps.integration-test.outcome == 'failure' }}
run: docker logs api-client-integration-app-db-1
- name: "Debug attribution"
if: ${{ failure() && steps.integration-test.outcome == 'failure' }}
run: docker logs api-client-integration-app-attribution-1
- name: "Debug api"
if: ${{ failure() && steps.integration-test.outcome == 'failure' }}
run: docker logs api-client-integration-app-api-1
- name: Cleanup
if: ${{ always() }}
run: ./scripts/cleanup-docker.sh
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ portal:
cp -r engines/api_client/ dpc-portal/vendor/api_client/
@docker build -f dpc-portal/Dockerfile . -t dpc-web-portal

api-client:
@docker compose -f docker-compose.yml -f docker-compose.api-client.yml build dpc_api_client

# Start commands
# ==============
Expand Down Expand Up @@ -178,6 +180,8 @@ portal-sh: ## Run a portal shell
portal-console: ## Run a rails console shell
@docker compose -f docker-compose.yml -f docker-compose.portals.yml exec -it dpc_portal bin/console

api-client-sh:
@docker compose -f docker-compose.api-client.yml run --remove-orphans --entrypoint "sh" dpc_api_client

# Build & Test commands
# ======================
Expand Down Expand Up @@ -228,3 +232,7 @@ unit-tests:

.PHONY: load-tests
load-tests: start-api-load-tests start-load-tests down-dpc-load-tests

.PHONY: ci-api-client-integration
ci-api-client-integration: docker-base secure-envs
@bash ./dpc-api-client-integration-test.sh
18 changes: 18 additions & 0 deletions docker-compose.api-client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
services:
dpc_api_client:
build:
context: .
dockerfile: engines/api_client/Dockerfile
image: dpc-api-client:latest
volumes:
# Mount specific directories to avoid overwriting
# precompiled assets (public/assets/) and node_modules
- "./engines/api_client:/api-client"
environment:
# Application settings
- GOLDEN_MACAROON=${GOLDEN_MACAROON}
- API_METADATA_URL=http://api:3002/api/v1
- API_ADMIN_URL=http://api:9900
- RUBY_YJIT_ENABLE=1
- SKIP_SIMPLE_COV=${SKIP_SIMPLE_COV:-}
- ENV=local
2 changes: 1 addition & 1 deletion docker-compose.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ services:
image: dpc-base:latest
build:
args:
PACE_CERT: $PACE_CERT
PACE_CERT: ${PACE_CERT:-}
context: .
dockerfile: docker/Dockerfiles/Dockerfile.base
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ services:
- ENV=local
- USE_BFD_MOCK=${USE_BFD_MOCK:-true}
- EMIT_AWS_METRICS=${EMIT_AWS_METRICS:-false}
- JACOCO=${REPORT_COVERAGE:-false}
- JACOCO=${REPORT_COVERAGE:-}
- DEBUG_MODE=${DEBUG_MODE:-false}
depends_on:
db:
Expand All @@ -56,7 +56,7 @@ services:
condition: service_healthy
environment:
- ENV=local
- JACOCO=${REPORT_COVERAGE:-false}
- JACOCO=${REPORT_COVERAGE:-}
- DEBUG_MODE=${DEBUG_MODE:-false}
ports:
- "3500:8080"
Expand All @@ -79,7 +79,7 @@ services:
- ./ops/config/decrypted/local.env
environment:
- ENV=local
- JACOCO=${REPORT_COVERAGE:-false}
- JACOCO=${REPORT_COVERAGE:-}
- EXPORT_PATH=/app/data
- AUTH_DISABLED=${AUTH_DISABLED:-false}
- DEBUG_MODE=${DEBUG_MODE:-false}
Expand Down
57 changes: 57 additions & 0 deletions dpc-api-client-integration-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
set -Ee

echo "┌-------------------───────────────────────┐"
echo "│ │"
echo "│ Running API Client Gem Integration Tests |"
echo "│ │"
echo "└------------─────────-------──────────────┘"

# Current working directory
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"

# Configure the Maven log level
export MAVEN_OPTS=-Dorg.slf4j.simpleLogger.defaultLogLevel=info

# Include secure environment variables
set -o allexport
[[ -f ${DIR}/ops/config/decrypted/local.env ]] && source ${DIR}/ops/config/decrypted/local.env
set +o allexport

# Remove jacocoReport directory
if [ -d "${DIR}/jacocoReport" ]; then
rm -r "${DIR}/jacocoReport"
fi

function _finally {
# don't shut it down if running on ci
if [ "$ENV" != 'github-ci' ]; then
echo "SHUTTING EVERYTHING DOWN"
docker compose -p api-client-integration-app down
docker volume rm api-client-integration-app_pgdata16
fi
}

trap _finally EXIT

# Build the application
mvn -T 1.5C clean compile -Perror-prone -B -V -ntp -DskipTests
mvn -T 1.5C package -Pci -ntp -DskipTests

echo "Starting api server for end-to-end tests"
USE_BFD_MOCK=true docker compose -p api-client-integration-app up api --wait

echo "Starting integration tests"
GOLDEN_MACAROON=$(curl -X POST http://localhost:9903/tasks/generate-token) \
SKIP_SIMPLE_COV=true \
docker compose -p api-client-integration-app \
-f docker-compose.yml -f docker-compose.api-client.yml \
run --remove-orphans \
--entrypoint "bundle exec rspec --order defined --tag type:integration" \
dpc_api_client

echo "┌───────────-------──────────-------------──┐"
echo "│ │"
echo "│ API Client Gem Integration Tests Complete |"
echo "│ │"
echo "└────────────────────--------------------───┘"
6 changes: 3 additions & 3 deletions dpc-api-client-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ echo "│ │"
echo "└───────────────────────┘"

# Build the container
docker build -f engines/api_client/Dockerfile engines/api_client -t api-client
docker compose -f docker-compose.api-client.yml build dpc_api_client

# Run the tests
echo "┌───────────────────────────┐"
echo "│ │"
echo "│ Running Api Gem Tests │"
echo "│ │"
echo "└───────────────────────────┘"
docker run --rm -v ${PWD}/engines/api_client/coverage:/api-client/coverage api-client bundle exec rspec
docker run --rm api-client bundle exec rubocop
docker run --rm -v ${PWD}/engines/api_client/coverage:/api-client/coverage dpc-api-client bundle exec rspec
docker run --rm dpc-api-client bundle exec rubocop

echo "┌────────────────────────────────┐"
echo "│ │"
Expand Down
12 changes: 6 additions & 6 deletions engines/api_client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ RUN mkdir /api-client
WORKDIR /api-client

# Copy over the files needed to fetch dependencies
COPY Gemfile Gemfile.lock api_client.gemspec /api-client/
COPY lib /api-client/lib
COPY engines/api_client/Gemfile engines/api_client/Gemfile.lock engines/api_client/api_client.gemspec /api-client/
COPY engines/api_client/lib /api-client/lib
RUN gem install bundler --no-document && \
bundle config set force_ruby_platform true && \
bundle install

COPY app /api-client/app
COPY spec /api-client/spec
COPY coverage /api-client/coverage
COPY .rubocop.yml /api-client/.rubocop.yml
COPY engines/api_client/app /api-client/app
COPY engines/api_client/spec /api-client/spec
COPY engines/api_client/coverage /api-client/coverage
COPY engines/api_client/.rubocop.yml /api-client/.rubocop.yml
8 changes: 0 additions & 8 deletions engines/api_client/Makefile

This file was deleted.

27 changes: 17 additions & 10 deletions engines/api_client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,27 @@ And then execute:
$ bundle install
```

## Testing
Build the docker image

In the api_client directory
## Debugging and Development
To build an image, use the `make` command in the project root directory.
```bash
$ make build
Comment on lines -26 to -28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having this here and not in the root make file was a long standing pet peeve!

make api-client
```

Run the tests until they pass

To ssh into a Docker container with the dpc_client code, use the `make` command in the project root directory.
```bash
make api-client-sh
```
$ make test

## Testing
Test using `make` commands in the project root directory.

### Unit Tests
```bash
make ci-api-client
```

Jump into the docker shell for iterative development
### Integration tests with the API
```bash
make ci-api-client-integration
```
make run
```
Loading