Skip to content

Commit

Permalink
build(repo): run tests in CI (#22)
Browse files Browse the repository at this point in the history
* build(repo): run tests in CI

run integration tests on main, and local integration tests on PRs

* ci(repo): rename local-integration test

* ci(repo): correct docker-compose down file path

* ci(repo): stop mono service in runner

* ci(repo): check mono service status

* ci(repo): move mono stop command later

* ci(repo): debug echo in CI

* ci(repo): killall monos

* ci(repo): sudo kill mono

* ci(repo): fix nx arch-specific package installation

* ci: add dummy CAMUNDA_CLUSTER_ID

* ci(repo): add dummy CAMUNDA_CLUSTER_REGION

* ci(repo): get tests to pass locally

* ci(repo): debug token issue

* ci: add trace logging of token

* ci(repo): stringify token in trace message

* ci(repo): trace log client id for token

* ci(repo): use 8.4.1 for local integration tests

* docs(repo): add contribution instructions

* docs(repo): add command to run local integration test

* build(oauth): run tests using src

* build(oauth): move jest config to package.json

* test(oauth): add jest transform to config

* refactor(repo): flatten to a single package (#24)

* refactor(repo): flatten to a single package

there is now only a single package, all APIs are included

* test(repo): fix tests
  • Loading branch information
jwulf authored Feb 29, 2024
1 parent cf541c9 commit 240d79a
Show file tree
Hide file tree
Showing 302 changed files with 9,243 additions and 72,683 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
packages/*/dist/
dist/*
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"prettier",
"plugin:prettier/recommended"
],
"ignorePatterns": ["dist/"],
"rules": {
// Define your rules, for example:
"semi": "off",
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ jobs:
with:
node-version: "18" # Specify a Node.js version

- name: Remove package-lock.json # This is to work around https://github.com/npm/cli/issues/4828
run: rm -f package-lock.json

- name: Install dependencies
run: npm install
env:
Expand All @@ -38,8 +41,8 @@ jobs:
git fetch
git checkout ${{ github.head_ref }}
# Add, commit, and push changes
git add -A
# Add, commit, and push changes, ignoring package-lock.json
git diff --name-only | grep -v 'package-lock.json' | xargs git add
git diff --staged --quiet || git commit -m "Apply Prettier formatting"
git push origin ${{ github.head_ref }}
env:
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Integration Tests

on:
push:
branches:
- main

jobs:
integration:
runs-on: ubuntu-latest
environment: integration
steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "18" # Specify a Node.js version

# This is to force nx arch-specific packages to correctly install
# This is to work around https://github.com/npm/cli/issues/4828
- name: Remove package-lock.json
run: rm -f package-lock.json

- name: Install dependencies
run: npm install

- name: Run Integration Tests
run: |
lerna run test:integration
env:
ZEEBE_ADDRESS: ${{ secrets.ZEEBE_ADDRESS }}
ZEEBE_CLIENT_ID: ${{ secrets.ZEEBE_CLIENT_ID }}
ZEEBE_AUTHORIZATION_SERVER_URL: ${{ secrets.ZEEBE_AUTHORIZATION_SERVER_URL }}
ZEEBE_CLIENT_SECRET: ${{ secrets.ZEEBE_CLIENT_SECRET }}
ZEEBE_TOKEN_AUDIENCE: ${{ secrets.ZEEBE_TOKEN_AUDIENCE }}
CAMUNDA_CREDENTIALS_SCOPES: ${{ secrets.CAMUNDA_CREDENTIALS_SCOPES }}
CAMUNDA_OAUTH_URL: ${{ secrets.CAMUNDA_OAUTH_URL }}
CAMUNDA_TASKLIST_BASE_URL: ${{ secrets.CAMUNDA_TASKLIST_BASE_URL }}
CAMUNDA_OPERATE_BASE_URL: ${{ secrets.CAMUNDA_OPERATE_BASE_URL }}
CAMUNDA_OPTIMIZE_BASE_URL: ${{ secrets.CAMUNDA_OPTIMIZE_BASE_URL }}
53 changes: 53 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Run Local Integration Tests

on: [push, pull_request]

jobs:
local_integration:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "18" # Specify a Node.js version

# This is to force nx arch-specific packages to correctly install
# This is to work around https://github.com/npm/cli/issues/4828
- name: Remove package-lock.json
run: rm -f package-lock.json

- name: Install dependencies
run: npm install

# Workaround for https://github.com/actions/runner-images/issues/2821
- name: Remove mono blocking 8084 port
run: sudo kill -9 $(sudo lsof -t -i:8084)

- name: Set up Docker Compose
run: |
docker-compose -f docker/docker-compose.yml up -d
- name: Run Integration Tests
run: |
lerna run test:local-integration
env:
ZEEBE_SECURE_CONNECTION: false
ZEEBE_ADDRESS: localhost:26500
ZEEBE_CLIENT_ID: zeebe
ZEEBE_AUTHORIZATION_SERVER_URL: http://localhost:18080/auth/realms/camunda-platform/protocol/openid-connect/token
ZEEBE_CLIENT_SECRET: zecret
ZEEBE_TOKEN_AUDIENCE: zeebe.camunda.io
CAMUNDA_CREDENTIALS_SCOPES: Zeebe,Tasklist,Operate,Optimize
CAMUNDA_OAUTH_URL: http://localhost:18080/auth/realms/camunda-platform/protocol/openid-connect/token
CAMUNDA_TASKLIST_BASE_URL: http://localhost:8082
CAMUNDA_OPERATE_BASE_URL: http://localhost:8081
CAMUNDA_OPTIMIZE_BASE_URL: http://localhost:8081
CAMUNDA_TEST_TYPE: local
DEBUG: camunda:token

- name: Cleanup
if: always()
run: docker-compose -f docker/docker-compose.yml down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,5 @@ dist

.DS_Store

*.env
*.env
!docker/.env
File renamed without changes.
File renamed without changes.
74 changes: 74 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Contributing to @camunda8/sdk

Thank you for considering contributing to @camunda8/sdk! We welcome contributions from the community to make our package even better.

## Getting Started

To get started with contributing, please follow these steps:

1. Fork the repository and clone it to your local machine.
2. Install the dependencies by running `npm install`.
3. Make your changes or additions to the codebase.
4. Write tests to cover your changes and ensure existing tests pass.
5. Run the tests using `npm test` to make sure everything is working correctly.
6. Commit your changes and push them to your forked repository.
7. Submit a pull request to the main repository.

## Running tests

Run all the unit tests with `lerna run test`.

### Integration tests

Integration tests can be run against Self-Managed or against Camunda SaaS.

To run integration tests against Camunda SaaS, but credentials for a Camunda SaaS API Client with scopes for all components in the environment, then run the integration tests against Camunda SaaS with `lerna run test:integration`.

To run the integration tests against Self-Managed, you can use either your own Self-Managed instance, or start one locally using Docker.

To start one locally, run `docker compose -f docker/docker-compose.yml up -d`.

Put the following credentials in the environment:

```bash
# Self-Managed
export ZEEBE_SECURE_CONNECTION=false
export ZEEBE_ADDRESS='localhost:26500'
export ZEEBE_CLIENT_ID='zeebe'
export ZEEBE_CLIENT_SECRET='zecret'
export ZEEBE_AUTHORIZATION_SERVER_URL='http://localhost:18080/auth/realms/camunda-platform/protocol/openid-connect/token'
export ZEEBE_TOKEN_AUDIENCE='zeebe.camunda.io'
export CAMUNDA_CREDENTIALS_SCOPES='Zeebe,Tasklist,Operate,Optimize'
export CAMUNDA_OAUTH_URL='http://localhost:18080/auth/realms/camunda-platform/protocol/openid-connect/token'
export CAMUNDA_TASKLIST_BASE_URL='http://localhost:8082'
export CAMUNDA_OPERATE_BASE_URL='http://localhost:8081'
export CAMUNDA_OPTIMIZE_BASE_URL='http://localhost:8083'
export CAMUNDA_TEST_TYPE='local'
```

Now run the integration tests against Self-Managed with `lerna run test:local-integration`.

## Code Style

We follow a specific code style in our project to maintain consistency. Please make sure to adhere to the following guidelines:

- Run `lerna run lint` to lint your code with ESLint.
- Run `lerna run prettify` to format your code to the project standard.

## Issue Reporting

If you encounter any bugs or issues while using @camunda/sdk, please report them in the [issue tracker](https://github.com/camunda-community-hub/camunda-8-js-sdk/issues). Provide as much detail as possible, including steps to reproduce the issue.

## Feature Requests

If you have any ideas or feature requests for @camunda/sdk, please submit them in the [issue tracker](https://github.com/camunda-community-hub/camunda-8-js-sdk/issues). We appreciate your feedback and suggestions.

## License

By contributing to @camunda/sdk, you agree that your contributions will be licensed under the [Apache License](https://opensource.org/licenses/Apache).

## Contact

If you have any questions or need further assistance, feel free to reach out to us at [your-email@example.com].

Happy contributing!
File renamed without changes.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Camunda 8 JavaScript SDK

This is the monorepo for the official Camunda 8 JavaScript SDK.

## Using the SDK in your project

Install the SDK as a dependency:

```bash
npm i @camunda/sdk
```
22 changes: 22 additions & 0 deletions docker/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Image versions ##
# CAMUNDA_CONNECTORS_VERSION=0.23.2
CAMUNDA_CONNECTORS_VERSION=8.4.1
CAMUNDA_OPTIMIZE_VERSION=8.4.1
CAMUNDA_PLATFORM_VERSION=8.4.1
CAMUNDA_WEB_MODELER_VERSION=8.4.1
ELASTIC_VERSION=8.9.0
KEYCLOAK_SERVER_VERSION=22.0.3
MAILPIT_VERSION=v1.7.0
POSTGRES_VERSION=14.5-alpine
HOST=localhost

## Configuration ##
# By default the zeebe api is public, when setting this to `identity` a valid zeebe client token is required
ZEEBE_AUTHENTICATION_MODE=identity
ZEEBE_CLIENT_ID=zeebe
ZEEBE_CLIENT_SECRET=zecret

# Set to 'true' to enable resource based authorizations for users and groups
# This can be used to limit access for users or groups to view/update specific
# processes and decisions in Operate and Tasklist
RESOURCE_AUTHORIZATIONS_ENABLED=false
2 changes: 2 additions & 0 deletions docker/connector-secrets.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# add secrets per line in the format NAME=VALUE
# WARNING: ensure not to commit changes to this file
Loading

0 comments on commit 240d79a

Please sign in to comment.