Skip to content

Commit

Permalink
Merge branch 'main' into fork-branch
Browse files Browse the repository at this point in the history
  • Loading branch information
meskill authored Sep 10, 2024
2 parents 48c84b4 + bfb5dc4 commit f30c1f4
Show file tree
Hide file tree
Showing 14 changed files with 503 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Benchmark PR
on:
pull_request:
paths: ["projects/**"]
types: [opened, reopened, edited, synchronize, labeled]
types: [opened, reopened, synchronize, labeled]
branches: [main]

concurrency:
Expand Down
128 changes: 128 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
- Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

- The use of sexualized language or imagery, and sexual attention or
advances of any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email
address, without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[email protected].
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
108 changes: 108 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
### Objective

Participants must implement a GraphQL API that resolves data from an upstream REST API that is deployed on port `3000`.

### Predefined Schema

The GraphQL schema that you need to implement is specified in the [schema.graphql](./schema.graphql) in the root of this repository.

### Data Source (Upstream REST API)

On the CI your GraphQL server will need to fetch data from the upstream REST API at:

**Base URL**: `http://localhost:3000`

### Endpoints

- **GET** `/posts`
_Returns a list of posts._

- **GET** `/posts/:id`
_Returns a post by ID._

- **GET** `/users`
_Returns a list of users._

- **GET** `/users/:id`
_Returns a user by ID._

- **GET** `/users?id=1&id=2&id=3`
_Returns multiple users with IDs specified in query parameters._

The structure of the REST API responses will match the GraphQL schema fields.

### GraphQL server

Your GraphQL server should start on url `http://localhost:8000/graphql` and serve `POST` Graphql requests on it.

## Getting Started

1. Fork this repository
2. Clone the repository locally or run the codespace of your choice
3. Add new folder to `./projects` folder with your username. Copy the `/template` folder content from the repository root to your folder to populate required files.
4. Add the code of the implementation inside the folder
- you could use any language or tool by your choice that allows you to create the required GraphQL server. Just make sure the solution could be replicated in Github Actions environment.
- use the `schema.graphql` file from the root of the repo. Feel free to copy the file to your folder and change it the way you needed to work properly, but don't change the structure of types
5. Add `run.sh` file that installs required tools and runs the server
- the script is running on [Github Hosted runner](https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners). List of available tools and packages could be found [here](https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md)
- first add installation and build steps for required tools and code. E.g. `npm i` or `cargo build --release`
- add steps to start the server. E.g. `npm start` or `cargo run --release`
- make sure the script is marked as executable `chmod +x run.sh`
6. Make sure your code is working and handles GraphQL requests
7. Commit and push changes to your fork
8. Create a pull request from your fork into original repository

### Run mock server locally

To run the mock server locally you need a [Rust toolchain](https://rustup.rs) installed.

To run the mock server in the root of the repo run:

```sh
cargo run -p mock-api
```

The server will start on `http://localhost:3000` and will serve the endpoints mentioned in [data source](#data-source-upstream-rest-api)

### Run test suite locally

To run the whole test suite locally you need a [Rust toolchain](https://rustup.rs) installed.

For the first time you need to build the mock server code (one-time run):

```sh
cargo build -p mock-api
```

After finishing the command you can use following command to run test suite:

```sh
cargo run
```

If you need to run only specific project, specify this project as option with name of the directory of the project:

```sh
cargo run -- --project tailcall
```

## How implementation is checked

1. Build everything that is required to run test environment and custom implementation
2. Start the test environment to validate response: mock server and reference server that is used to test implementation correctness
3. Run correctness tests
4. Run the benchmark
5. Run correctness tests again

### Testing correctness

For testing the correctness repeat next process multiple times:

1. Regenerate mocks on mock-api server
2. For every request in `/tests` directory execute the request to user implementation
3. Execute the same request for reference implementation
4. Compare the results and in case they are mismatch throw an error

### Benchmarking the performance

Ran many requests in parallel to the server with tools like `wrk` or `k6` to collect info about provided RPS and latency
Loading

0 comments on commit f30c1f4

Please sign in to comment.