Skip to content

Commit 57cba8f

Browse files
committed
feat: add apollo studio extension
1 parent aef7bb2 commit 57cba8f

File tree

13 files changed

+9952
-15
lines changed

13 files changed

+9952
-15
lines changed

.github/workflows/assigne.yml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
jobs:
88
assignee:
99
name: 'check assignee'
10+
runs-on: ubuntu-latest
1011

1112
steps:
1213
- name: Check if there is at least one assignee

.github/workflows/changelog.yml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
jobs:
88
changelog:
99
name: 'check changelog change'
10+
runs-on: ubuntu-latest
1011

1112
steps:
1213
- name: Fail if no changelog change when needed

.github/workflows/ci.yml

+9-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66

77
jobs:
88
clippy_check:
9+
name: Lint
10+
runs-on: ubuntu-latest
911
steps:
1012
- uses: actions/checkout@v2
1113
- uses: actions-rs/toolchain@v1
@@ -18,16 +20,17 @@ jobs:
1820
args: --all-features
1921
build_and_test:
2022
name: Build CI
23+
runs-on: ubuntu-latest
2124
steps:
2225
- uses: actions/checkout@v2
2326
- uses: actions-rs/toolchain@v1
2427
with:
2528
toolchain: stable
26-
- uses: actions-rs/cargo@v1
27-
with:
28-
command: test
29-
args: --verbose
3029
- uses: actions-rs/cargo@v1
3130
with:
32-
command: check
33-
args: --all-features --verbose
31+
command: test
32+
args: --verbose
33+
- uses: actions-rs/cargo@v1
34+
with:
35+
command: build
36+
args: --release --all-features --verbose

.github/workflows/label.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
jobs:
88
version-labels:
99
name: 'check version label'
10-
runs-on: self-hosted
10+
runs-on: ubuntu-latest
1111

1212
steps:
1313
- name: Check if version label is present

.github/workflows/on-publish.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: On publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
name: 'Create version and deploy'
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Create deployment
13+
id: deployment
14+
uses: actions/github-script@v2
15+
env:
16+
VERSION: ${{ secrets.GITHUB_REF }}
17+
REF: ${{ secrets.GITHUB_REF }}
18+
NAME: "async-graphql-extension-apollo-tracing"
19+
DIRECTORY: "async-graphql-extension-apollo-tracing"
20+
with:
21+
github-token: ${{ secrets.GITHUB_TOKEN }}
22+
previews: 'ant-man-preview,flash-preview'
23+
script: |
24+
const ref = process.env.GITHUB_SHA;
25+
const name = process.env.NAME;
26+
const version = process.env.GITHUB_REF.match(/refs\/tags\/(.*)/)[1];
27+
const directory = process.env.DIRECTORY;
28+
const { data: deployment } = await github.repos.createDeployment({
29+
owner: context.repo.owner,
30+
repo: context.repo.repo,
31+
ref: ref,
32+
environment: 'crates.io',
33+
auto_merge: false,
34+
required_contexts: [],
35+
payload: {
36+
version,
37+
name,
38+
directory,
39+
ref,
40+
},
41+
description: `Deploy ${name}@${version} on crates.io`,
42+
production_environment: true,
43+
});
44+

.github/workflows/publish.yml

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Publish
2+
3+
on: deployment
4+
5+
jobs:
6+
crates:
7+
name: Github-control CI
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Update deployment status
11+
id: status
12+
uses: actions/github-script@v2
13+
env:
14+
DEPLOYMENT_ID: ${{ github.event.deployment.id }}
15+
with:
16+
github-token: ${{ secrets.GITHUB_TOKEN }}
17+
previews: 'ant-man,flash'
18+
script: |
19+
const name = context.payload.deployment.payload.name;
20+
const version = context.payload.deployment.payload.version;
21+
const cratesUrl = `https://crates.io/crates/async-graphql-extension-apollo-tracing/${version}`;
22+
const { data: deploymentStatus } = github.repos.createDeploymentStatus({
23+
owner: context.repo.owner,
24+
repo: context.repo.repo,
25+
deployment_id: process.env.DEPLOYMENT_ID,
26+
environment_url: cratesUrl,
27+
description: `Deployed async-graphql-extension-apollo-tracing@${version} on crates.io`,
28+
auto_inactive: false,
29+
state: 'in_progress',
30+
});
31+
const directory = context.payload.deployment.payload.directory;
32+
console.log(`::set-output name=directory::${directory}`)
33+
- name: Checkout code
34+
uses: actions/checkout@v2
35+
with:
36+
ref: ${{ github.event.deployment.payload.ref }}
37+
38+
- name: Git config
39+
run: |
40+
git config user.name "Github actions"
41+
git config user.email "[email protected]"
42+
43+
- name: Install
44+
uses: actions-rs/toolchain@v1
45+
with:
46+
toolchain: stable
47+
48+
- name: Test
49+
uses: actions-rs/cargo@v1
50+
with:
51+
command: test
52+
args: --verbose
53+
- name: Build
54+
uses: actions-rs/cargo@v1
55+
with:
56+
command: build
57+
args: --release --all-features --verbose
58+
- name: Publish
59+
uses: actions-rs/cargo@v1
60+
with:
61+
command: login
62+
args: ${{ secrets.CRATES_IO_API_TOKEN }}
63+
- name: Publish
64+
id: publish
65+
uses: actions-rs/cargo@v1
66+
with:
67+
command: publish
68+
- name: Update deployment status
69+
if: always()
70+
uses: actions/github-script@v2
71+
env:
72+
DEPLOYMENT_ID: ${{ github.event.deployment.id }}
73+
PUBLISH_STATE: ${{ steps.publish.outputs.state }}
74+
with:
75+
github-token: ${{ secrets.GITHUB_TOKEN }}
76+
previews: 'ant-man,flash'
77+
script: |
78+
const name = context.payload.deployment.payload.name;
79+
const version = context.payload.deployment.payload.version;
80+
const cratesUrl = `https://crates.io/crates/async-graphql-extension-apollo-tracing/${version}`;
81+
const state = 'success';
82+
const { data: deploymentStatus } = github.repos.createDeploymentStatus({
83+
owner: context.repo.owner,
84+
repo: context.repo.repo,
85+
deployment_id: process.env.DEPLOYMENT_ID,
86+
environment_url: cratesUrl,
87+
description: `Deployed async-graphql-extension-apollo-tracing@${version} on crates.io`,
88+
auto_inactive: false,
89+
state,
90+
});

CHANGELOG.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
### Feat
10+
11+
- Opensource Brevz Apollo Extension
12+
13+
## [0.1.0]
14+
15+
### Added
16+
17+
- Boot repo
18+
19+
[Unreleased]: https://github.com/Miaxos/async_graphql_apollo_studio_extension/compare/v0.1.0...HEAD

Cargo.toml

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
[package]
2-
name = "async_graphql_apollo_studio_extension"
2+
name = "async-graphql-extension-apollo-tracing"
33
version = "0.1.0"
44
authors = ["Anthony Griffon <[email protected]>"]
5+
description = "An async_graphql extension to send traces & metrics to Apollo Studio"
6+
readme = "README.md"
7+
repository = "https://github.com/Miaxos/async_graphql_apollo_studio_extension"
8+
documentation = "https://github.com/Miaxos/async_graphql_apollo_studio_extension"
9+
license = "MIT"
10+
keywords = ["async_graphql", "futures", "async", "graphql", "apollo", "studio"]
11+
categories = ["network-programming", "asynchronous"]
512
edition = "2018"
613

714
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
815

916
[dependencies]
1017
protobuf = { version = "2.18.1", features = ["bytes"] }
1118
libflate = "1"
12-
async-graphql = {version = "2.8.6", features = ["tracing"] }
19+
async-graphql = {version = "2.9.*", features = ["tracing"] }
1320
tracing = "0.1.*"
1421
tracing-futures = { version = "0.2.5", default-features = false, features = ["tokio", "futures-03", "std"] }
15-
futures = "0.3.8" # An implementation of futures and streams featuring zero allocations, composability, and itera…
22+
futures = "0.3.*" # An implementation of futures and streams featuring zero allocations, composability, and itera…
1623
chrono = "0.4.15"
1724
tokio = { version = "1", features = ["full"] }
25+
reqwest = { version = "0.11.*", features = ["json"] }
26+
async-trait = "0.1.*"
27+
serde_json = "1.0.*" # A JSON serialization file format

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
async-graphql-extension-apollo-tracing
2+
====
3+
4+
async-graphql-extension-apollo-tracing is an open-source extension for the crates [async_graphql](https://github.com). The purpose of this extension is to provide a simple way to create & send your graphql metrics to [Apollo Studio](https://studio.apollographql.com/).

0 commit comments

Comments
 (0)