Skip to content

Commit

Permalink
Merge branch 'main' into 412-retiremsa
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeCap08055 committed Sep 16, 2024
2 parents efa9a2a + cfdf57c commit 8a78314
Show file tree
Hide file tree
Showing 34 changed files with 2,847 additions and 2,262 deletions.
102 changes: 102 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: E2E Tests

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
service-matrix:
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.determine-matrix.outputs.changes }}
# NOTE: only account E2E tests enabled in pipeline currently; add other services as they are updated
# IF you add a new filter it ALSO needs to be here
services: >-
["account"]
# Resolves to true if it should run everything, aka when common files change
run-all: ${{ steps.determine-matrix.outputs.changes.common }}
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: determine-matrix
with:
# Adding a filter? Check for the need to add to the outputs as well
filters: |
common:
- 'Docker/**'
- 'tools/ci-k6/**'
- '.github/**'
- 'docker-compose.yaml'
- 'docker-compose-e2e.*.yaml'
- 'libs/types'
account:
- 'apps/account-api/**'
- 'apps/account-worker/**'
- 'libs/account-lib/**'
graph:
- 'apps/graph-api/**'
- 'apps/graph-worker/**'
- 'libs/graph-lib/**'
content-publishing:
- 'apps/content-publishing-api/**'
- 'apps/content-publishing-worker/**'
- 'libs/content-publishing-lib/**'
content-watcher:
- 'apps/content-watcher/**'
- 'libs/content-watcher-lib/**'
build:
name: '[${{ matrix.service }}] E2E Tests'
runs-on: ubuntu-latest
needs: service-matrix
strategy:
fail-fast: false
matrix:
service: ${{ fromJson(needs.service-matrix.outputs.services) }}
steps:
- name: Run or Skip
id: should
run: echo "RUN=${{ needs.service-matrix.outputs.run-all || contains(fromJson(needs.service-matrix.outputs.changes), matrix.service) }}" >> "$GITHUB_OUTPUT"

- name: Checkout
if: ${{ steps.should.outputs.RUN == 'true' }}
uses: actions/checkout@v4

- name: Install Node.js
if: ${{ steps.should.outputs.RUN == 'true' }}
uses: actions/setup-node@v4
with:
node-version: 20.16.0
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
cache-dependency-path: tools/ci-k6/package-lock.json

- name: Install dependencies
if: ${{ steps.should.outputs.RUN == 'true' }}
run: npm ci

- name: Start Frequency
if: ${{ steps.should.outputs.RUN == 'true' }}
# NOTE: the 'sleep' below can be shortened or possibly eliminated once we switch from the 'dsnp/instant-seal-node-with-deployed-schemas'
# to the 'frequencychain/standalone-node' with schemas in the genesis block (after Frequency 1.13 is deployed to Mainnet & the image is updated)
run: |
docker compose -f docker-compose.yaml -f docker-compose-e2e.${{ matrix.service }}.yaml --profile e2e up -d
sleep 15
# TODO: make a service-agnostic setup script, or make service-specific setup scripts all in one place
- name: Generate Provider and Capacity
if: ${{ steps.should.outputs.RUN == 'true' }}
working-directory: apps/account-api/test/setup
run: npm ci && npm run main

- name: Run E2E Tests
if: ${{ steps.should.outputs.RUN == 'true' }}
run: npm run test:e2e:${{ matrix.service }}
- name: Stop Docker Compose
if: ${{ steps.should.outputs.RUN == 'true' || failure() }}
run: docker compose -f docker-compose.yaml -f docker-compose-e2e.${{ matrix.service }}.yaml --profile e2e down
17 changes: 2 additions & 15 deletions .github/workflows/load-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,12 @@ jobs:
working-directory: tools/ci-k6
run: npm ci

- name: Set up Docker Buildx
if: ${{ steps.should.outputs.RUN == 'true' }}
uses: docker/setup-buildx-action@v3
# Use GitHub Container Registry instead due to rate limits
with:
buildkitd-config-inline: |
[registry."ghcr.io"]
- name: Login to DockerHub
if: ${{ steps.should.outputs.RUN == 'true' }}
uses: docker/login-action@v3
with:
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_TOKEN}}

- name: Start Frequency
if: ${{ steps.should.outputs.RUN == 'true' }}
run: |
docker compose -f docker-compose.yaml -f docker-compose-k6.${{ matrix.service }}.yaml up -d frequency
sleep 5
sleep 15
- name: Generate Provider and Capacity
if: ${{ steps.should.outputs.RUN == 'true' }}
working-directory: tools/ci-k6
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ services/*/apps/api/src/metadata.ts
services/*/docs/index.html
**/metadata.ts
openapi-specs/*
**/target/**
jest.config.json
38 changes: 38 additions & 0 deletions Docker/Dockerfile.mock-webhook-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Stage 1: Build the application using static linking with the GNU toolchain
FROM rust:bullseye AS builder

# Set the working directory inside the container
WORKDIR /app

# Copy the Cargo.toml and Cargo.lock files to cache dependencies
COPY rust-webhook-server/Cargo.toml rust-webhook-server/Cargo.lock ./

# Create a dummy main.rs to allow Cargo to fetch dependencies
RUN mkdir src && echo "fn main() {}" > src/main.rs

# Fetch dependencies
RUN cargo build --release && rm -rf src target/release/rust-webhook-server

# Copy the rest of the application source code
COPY rust-webhook-server/ .
RUN touch src/main.rs

# Build the actual Rust application, enabling static linking for the standard library
RUN cargo build --release

# Stage 2: Use a minimal base image to run the application
FROM debian:bullseye

RUN apt-get update & apt-get install -y extra-runtime-dependencies & rm -rf /var/lib/apt/lists/*

# Set the working directory inside the container
WORKDIR /app

# Copy the statically linked binary from the builder stage
COPY --from=builder /app/target/release/rust-webhook-server .

# Expose the port your application will run on (adjust as necessary)
EXPOSE 3001

# Run the binary
CMD ["./rust-webhook-server"]
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ generate-openapi:
generate-swagger-ui:
@npm run generate:swagger-ui

test: $(TEST_TARGETS)
# test-e2e: $(E2E_TARGETS)
.PHONY test: $(TEST_TARGETS)
test-e2e: $(E2E_TARGETS)
# test-k6: $(K6_TARGETS)

lint:
Expand All @@ -54,8 +54,8 @@ $(SWAGGER_TARGETS): swagger-%: openapi-%
$(TEST_TARGETS):
@npm run test:$(@:test-%=%)

# $(E2E_TARGETS):
# @( cd apps/$(@:test-e2e-%=%) ; npm run test:e2e )
$(E2E_TARGETS):
@npm run test:e2e:$(@:test-e2e-%=%)

# $(K6_TARGETS):
# @( cd apps/$(@:test-k6-%=%) ; npm run test:k6 )
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,31 +68,31 @@ Each Gateway service is an independent microservice.
<summary>Account Service</summary>

- [API Documentation](https://projectlibertylabs.github.io/gateway/account)
- [README](./services/account/README.md)
- [README](./developer-docs/account/README.md)

</details>

<details>
<summary>Graph Service</summary>

- [API Documentation](https://projectlibertylabs.github.io/gateway/graph/)
- [README](./services/graph/README.md)
- [README](./developer-docs/graph/README.md)

</details>

<details>
<summary>Content Publishing Service</summary>

- [API Documentation](https://projectlibertylabs.github.io/gateway/content-publishing/)
- [README](./services/content-publishing/README.md)
- [README](./developer-docs/content-publishing/README.md)

</details>

<details>
<summary>Content Watcher Service</summary>

- [API Documentation](https://projectlibertylabs.github.io/gateway/content-watcher/)
- [README](./services/content-watcher/README.md)
- [README](./developer-docs/content-watcher/README.md)

</details>

Expand Down
Loading

0 comments on commit 8a78314

Please sign in to comment.