Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
basic config
Browse files Browse the repository at this point in the history
Signed-off-by: Phil Prasek <[email protected]>
  • Loading branch information
prasek committed Jun 21, 2021
1 parent 1d18a50 commit b507ca3
Show file tree
Hide file tree
Showing 42 changed files with 2,103 additions and 2 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
k8s:
name: CI - k8s
runs-on: ubuntu-18.04
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: update kind
run: |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64
chmod +x ./kind
mkdir -p $HOME/.kind/bin
mv ./kind $HOME/.kind/bin/kind
echo "PATH=$HOME/.kind/bin:$PATH" >> ${GITHUB_ENV}
-
name: test-k8s
run: .scripts/ci-k8s.sh
83 changes: 83 additions & 0 deletions .github/workflows/rebase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Rebase
on:
issue_comment:
types: [created]
jobs:
verify:
name: Verify
runs-on: ubuntu-18.04
env:
OK: |
${{
contains(github.event.comment.body, '/rebase') &&
(github.event.issue.pull_request != '') &&
(
(github.event.issue.author_association == 'OWNER') ||
(github.event.issue.author_association == 'COLLABORATOR') ||
(github.event.issue.author_association == 'CONTRIBUTOR') ||
(github.event.issue.author_association == 'MEMBER')
)
}}
outputs:
ok: ${{ env.OK }}
comment-id: ${{ steps.comment.outputs.comment-id }}
steps:
- name: Info
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Create or update comment
id: comment
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.issue.number }}
body: Rebasing ...

rebase:
name: Rebase
runs-on: ubuntu-18.04
needs: verify
if: needs.verify.outputs.ok
steps:
- name: with PAT
uses: actions/checkout@v2
with:
token: ${{ secrets.PAT }}
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
- name: Automatic Rebase
uses: cirrus-actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.PAT }}

ok-msg:
name: Success comment
runs-on: ubuntu-18.04
needs: [verify, rebase]
if: success() && needs.verify.outputs.ok
steps:
- name: Create or update comment
id: comment
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.issue.number }}
comment-id: ${{ needs.verify.outputs.comment-id }}
body: |
Rebase complete!
edit-mode: replace
reactions: hooray

fail-msg:
name: Failure comment
runs-on: ubuntu-18.04
needs: [verify, rebase]
if: failure() || !needs.verify.outputs.ok
steps:
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.issue.number }}
comment-id: ${{ needs.verify.outputs.comment-id }}
body: |
Unable to rebase. Check the action logs for details.
edit-mode: replace
reactions: confused
40 changes: 40 additions & 0 deletions .github/workflows/subgraph-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Subgraph Publish
on:
push:
branches: [ main ]
paths:
- "subgraphs/**"

jobs:
subgraph-publish:
runs-on: ubuntu-18.04
strategy:
matrix:
include:
- subgraph: "products"
routing_url: "http://products:4000/graphql"
rover-version: "latest"
- subgraph: "users"
routing_url: "http://users:4000/graphql"
rover-version: "latest"
- subgraph: "inventory"
routing_url: "http://inventory:4000/graphql"
rover-version: "latest"
env:
APOLLO_KEY: ${{ secrets.APOLLO_KEY }}
GRAPH_REF: supergraph-router@dev

name: ${{ matrix.subgraph }}

steps:
- uses: actions/checkout@v2
- name: install rover
env:
ROVER_VERSION: ${{ matrix.rover-version }}
run: |
curl -sSL https://rover.apollo.dev/nix/$ROVER_VERSION | sh
echo "PATH=$PATH:$HOME/.rover/bin" >> ${GITHUB_ENV}
- name: check
run: rover subgraph check $GRAPH_REF --schema subgraphs/dev/${{ matrix.subgraph }}/${{ matrix.subgraph }}.graphql --name ${{ matrix.subgraph }}
- name: publish
run: rover subgraph publish $GRAPH_REF --routing-url ${{ matrix.routing_url }} --schema subgraphs/dev/${{ matrix.subgraph }}/${{ matrix.subgraph }}.graphql --name ${{ matrix.subgraph }}
124 changes: 124 additions & 0 deletions .github/workflows/supergraph-build-webhook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Supergraph Build Webhook

on:
schedule:
- cron: '*/5 * * * *'
repository_dispatch:
types: [studio-build-webhook]

jobs:
supergraph-build-webhook:
runs-on: ubuntu-18.04
strategy:
matrix:
include:
- graph-ref: "supergraph-router@dev"
target-branch: "main"
target-file: "router/dev/supergraph.graphql"
pr-branch: "supergraph-router-dev"
name: ${{ matrix.target-branch }}
concurrency:
group: ${{ matrix.target-branch }}
cancel-in-progress: true
env:
APOLLO_KEY: ${{ secrets.APOLLO_KEY }}
GRAPH_REF: ${{ matrix.graph-ref }}
SUPERGRAPH: ${{ matrix.target-file }}
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ matrix.target-branch }}
-
name: install rover
run: |
curl -sSL https://rover.apollo.dev/nix/latest | sh
echo "PATH=$PATH:$HOME/.rover/bin" >> ${GITHUB_ENV}
-
id: pre-check
run: |
SHA=$(shasum ${{ matrix.target-file }} | awk '{print $1}')
echo "::set-output name=sha::$SHA"
echo "::set-output name=sha-short::$(git rev-parse --short $SHA)"
-
name: supergraph fetch
run: rover supergraph fetch $GRAPH_REF > ${{ matrix.target-file }}
-
id: check
run: |
echo "::set-output name=result::$(git diff --name-only | grep -E '${{ matrix.target-file }}')"
SHA=$(shasum $SUPERGRAPH | awk '{print $1}')
echo "::set-output name=sha::$SHA"
echo "::set-output name=sha-short::$(git rev-parse --short $SHA)"
-
name: validate
if: steps.check.outputs.result == '$SUPERGRAPH'
env:
RESULT: ${{ steps.check.outputs.result }}
SHA: ${{ steps.check.outputs.sha }}
SHA_SHORT: ${{ steps.check.outputs.sha-short }}
run: |
echo "RESULT: $RESULT"
echo "SHA: $SHA"
echo "SHA_SHORT: $SHA_SHORT"
DIFF=$(git diff $SUPERGRAPH)
echo "DIFF<<EOF" >> $GITHUB_ENV
echo "$DIFF" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "-----------------------"
echo "$SUPERGRAPH"
echo "-----------------------"
echo "$DIFF"
-
name: create pull request
id: cpr
if: steps.check.outputs.result == '$SUPERGRAPH'
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.PAT }}
committer: Supergraph Demo Bot <[email protected]>
author: Supergraph Demo Bot <[email protected]>
commit-message: Bump supergraph schema from ${{ steps.pre-check.outputs.sha-short }} to ${{ steps.check.outputs.sha-short }}
title: Bump ${{ env.GRAPH_REF }} from ${{ steps.pre-check.outputs.sha-short }} to ${{ steps.check.outputs.sha-short }}
body: |
Bump ${{ env.GRAPH_REF }} from ${{ steps.pre-check.outputs.sha-short }} to ${{ steps.check.outputs.sha-short }}
* Old: SHA1 ${{ steps.pre-check.outputs.sha }} ( ${{ steps.pre-check.outputs.sha-short }} )
* New: SHA1 ${{ steps.check.outputs.sha }} ( ${{ steps.check.outputs.sha-short }} )
<details>
<summary>${{ env.GRAPH_REF }} -> ${{ matrix.target-branch }}</summary>
```diff
${{ env.DIFF }}
```
</details>
branch: ${{ matrix.pr-branch }}
base: ${{ matrix.target-branch }}
delete-branch: true
-
name: enable pull request automerge
if: |
steps.check.outputs.result == '$SUPERGRAPH' &&
steps.cpr.outputs.pull-request-operation == 'created' &&
matrix.target-branch == 'main'
uses: peter-evans/enable-pull-request-automerge@v1
with:
token: ${{ secrets.PAT }}
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
merge-method: squash
- name: Check output
if: |
steps.check.outputs.result == '\$SUPERGRAPH' &&
steps.cpr.outputs.pull-request-operation == 'created'
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
- name: No changes detected
if: |
steps.check.outputs.result == 0 ||
steps.cpr.outputs.pull-request-operation != 'created'
run: |
echo "No changes to '$GRAPH_REF' detected"
111 changes: 111 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

graph-api.env
docker.secrets

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids *.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

.DS_Store

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# lock file for demo to keep it simple
package-lock.json

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
7 changes: 7 additions & 0 deletions .scripts/ci-k8s.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

.scripts/k8s-up.sh
.scripts/k8s-smoke.sh
code=$?
.scripts/k8s-down.sh
exit $code
Loading

0 comments on commit b507ca3

Please sign in to comment.