Skip to content

chore(deps): bump the opentelemetry group across 1 directory with 10 updates #3818

chore(deps): bump the opentelemetry group across 1 directory with 10 updates

chore(deps): bump the opentelemetry group across 1 directory with 10 updates #3818

Workflow file for this run

name: build-router
on:
push:
branches:
- main
pull_request:
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
actions: write
contents: write
issues: read
checks: write
pull-requests: write
packages: write
id-token: write
env:
DOCKER_IMAGE_NAME: ghcr.io/graphql-hive/router
DOCKER_LICENSE: MIT
DOCKER_VENDOR: theguild
DOCKER_PLATFORMS: linux/amd64,linux/arm64
ZIG_VERSION: 0.15.1
BINARY_NAME: hive_router
jobs:
config:
name: check / config
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'pull_request' || (github.event_name == 'release' && startsWith(github.event.release.tag_name, 'hive-router/v'))
steps:
- name: checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
token: ${{ github.ref == 'refs/heads/main' && secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
- name: setup rust
uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606 # v1
- name: generate config schema
run: cargo router-config
- name: setup node
uses: the-guild-org/shared-config/setup@v1
with:
node-version-file: .node-version
- name: generate documentation
working-directory: docs/generator
run: npm run generate
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
name: upload config artifact
with:
name: router-config.schema.json
path: router-config.schema.json
if-no-files-found: error
- name: Upload config to release
uses: svenstaro/upload-release-action@29e53e917877a24fad85510ded594ab3c9ca12de # v2
if: ${{ github.event_name == 'release' }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: router-config.schema.json
asset_name: router-config.schema.json
tag: ${{ github.ref }}
- name: diff
run: git diff --pretty ./docs/README.md
- name: commit if changes
if: github.ref != 'refs/heads/main'
uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # v7.1.0
with:
file_pattern: ./docs/README.md
commit_message: "docs: update documentation"
commit_user_name: theguild-bot
commit_user_email: bot@the-guild.dev
commit_author: theguild-bot <bot@the-guild.dev> # dont use the actor as an author
- name: fail if changes
if: github.ref == 'refs/heads/main'
run: git diff --exit-code ./docs/README.md
binary:
name: publish / binary / ${{ matrix.name }}
if: |
github.event_name == 'push' || github.event_name == 'pull_request' || (
github.event_name == 'release' &&
(
startsWith(github.event.release.tag_name, 'hive-router/v') ||
startsWith(github.event.release.tag_name, 'node-addon/v')
)
)
runs-on: ${{ matrix.action_runner }}
strategy:
matrix:
include:
- name: linux_arm64
rust_target: aarch64-unknown-linux-gnu
zigbuild: true
zigbuild_target: aarch64-unknown-linux-gnu.2.28
action_runner: ubuntu-latest
- name: linux_amd64
rust_target: x86_64-unknown-linux-gnu
zigbuild: true
zigbuild_target: x86_64-unknown-linux-gnu.2.28
action_runner: ubuntu-latest
- name: macos_arm64
zigbuild: false
rust_target: aarch64-apple-darwin
action_runner: macos-15
- name: macos_amd64
zigbuild: false
rust_target: x86_64-apple-darwin
action_runner: macos-15
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
name: checkout
- name: setup rust (${{ matrix.rust_target }})
uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606 # v1
with:
target: ${{ matrix.rust_target }}
cache-key: ${{ matrix.name }}
# Only if using Zigbuild
- uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2
name: setup zig
if: ${{ matrix.zigbuild }}
with:
version: ${{ env.ZIG_VERSION }}
- run: cargo install cargo-zigbuild
name: install zigbuild
if: ${{ matrix.zigbuild }}
- name: zigbuild (${{ matrix.zigbuild_target }})
if: ${{ matrix.zigbuild }}
run: cargo zigbuild --release --target ${{ matrix.zigbuild_target }}
# Only if NOT using Zigbuild
- name: cargo build (${{ matrix.rust_target }})
run: cargo build --release --target ${{ matrix.rust_target }}
if: ${{ !matrix.zigbuild }}
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
name: upload router artifact
with:
name: hive_router_${{ matrix.name }}
path: |
target/${{ matrix.rust_target }}/release/${{ env.BINARY_NAME }}
if-no-files-found: error
# napi build will use zigbuild when cross compiling
- name: setup node
uses: the-guild-org/shared-config/setup@v1
with:
node-version-file: .node-version
- name: node-addon build (${{ matrix.rust_target }})
working-directory: lib/node-addon
env:
CROSS_COMPILE: ${{ matrix.zigbuild }}
TARGET: ${{ matrix.rust_target }}
run: npm run build
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
name: upload node addon artifact
with:
name: node_addon_${{ matrix.name }}
path: |
lib/node-addon/dist/*.node
if-no-files-found: error
- name: Upload binaries to router release
uses: svenstaro/upload-release-action@29e53e917877a24fad85510ded594ab3c9ca12de # v2
if: github.event_name == 'release' && startsWith(github.event.release.tag_name, 'hive-router/v')
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/${{ matrix.rust_target }}/release/${{ env.BINARY_NAME }}
asset_name: hive_router_${{ matrix.name }}
tag: ${{ github.ref }}
# NOTE: would publish from release.yaml but we need the artifacts. doing it from here is simpler
npm-publish:
name: publish / node-addon
runs-on: ubuntu-latest
needs:
- binary
if: github.event_name == 'release' && startsWith(github.event.release.tag_name, 'node-addon/v')
steps:
- name: checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: setup node
uses: the-guild-org/shared-config/setup@v1
with:
node-version-file: .node-version
- name: download node addon artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
pattern: node_addon_*
path: lib/node-addon
- name: prepare artifacts
working-directory: lib/node-addon
run: |
mv ./node_addon_linux_arm64/* ./dist
mv ./node_addon_linux_amd64/* ./dist
mv ./node_addon_macos_arm64/* ./dist
mv ./node_addon_macos_amd64/* ./dist
- name: publish
working-directory: lib/node-addon
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --provenance
- name: pack
working-directory: lib/node-addon
run: npm pack
- name: upload pack to release
uses: svenstaro/upload-release-action@29e53e917877a24fad85510ded594ab3c9ca12de # v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: lib/node-addon/*.tgz
tag: ${{ github.ref }}
docker:
name: build / docker
runs-on: ubuntu-latest
needs:
- binary
outputs:
docker_image_digest: ${{ steps.docker.outputs.digest }}
steps:
- name: checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: setup qemu
uses: docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4.1.0
- name: setup buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
- name: setup docker tags
id: meta
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6
with:
images: ${{ env.DOCKER_IMAGE_NAME }}
labels: |
org.opencontainers.image.licenses=${{ env.DOCKER_LICENSE }}
org.opencontainers.image.vendor=${{ env.DOCKER_VENDOR }}
tags: |
type=ref,event=pr
type=semver,pattern={{version}},value=${{ github.event.release.name }},enable=${{ github.event_name == 'release' && !github.event.release.prerelease }}
type=match,group=1,pattern=router/v(.*),value=${{ github.event.release.tag_name }},enable=${{ github.event_name == 'release' && !github.event.release.prerelease }}
type=sha
type=raw,value=latest,enable=${{ github.event_name == 'release' && !github.event.release.prerelease }}
- name: download binary artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
path: artifacts
pattern: hive_router_*
- name: prepare artifacts
run: |
mkdir -p ./target/linux/arm64
mkdir -p ./target/linux/amd64
mv ./artifacts/${{ env.BINARY_NAME }}_linux_arm64/${{ env.BINARY_NAME }} ./target/linux/arm64/${{ env.BINARY_NAME }}
mv ./artifacts/${{ env.BINARY_NAME }}_linux_amd64/${{ env.BINARY_NAME }} ./target/linux/amd64/${{ env.BINARY_NAME }}
ls -ltra ./target/linux/arm64/
ls -ltra ./target/linux/amd64/
- uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: build and push
id: docker
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
with:
file: ./docker/router.Dockerfile
context: .
platforms: ${{ env.DOCKER_PLATFORMS }}
push: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || github.event_name == 'release' || github.event_name == 'push' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: docker pr comment
uses: marocchino/sticky-pull-request-comment@0ea0beb66eb9baf113663a64ec522f60e49231c0 # v3
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }}
with:
header: ${{ github.workflow }}
message: |
🐋 This PR was built and pushed to the following [Docker images](https://github.com/graphql-hive?ecosystem=container&tab=packages&visibility=public):
**Image Names**: `${{ env.DOCKER_IMAGE_NAME }}`
**Platforms**: `${{ env.DOCKER_PLATFORMS }}`
**Image Tags**: `${{ steps.meta.outputs.tags }}`
<details>
<summary>Docker metadata</summary>
```json
${{ steps.docker.outputs.metadata }}
```
</details>
test-docker-image:
name: test / docker
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }}
needs:
- docker
steps:
- name: checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: run router image in background
run: |
echo "Docker image: ${{ env.DOCKER_IMAGE_NAME }}@${{ needs.docker.outputs.docker_image_digest }}"
docker run -d --name router -p 4000:4000 \
-e SUPERGRAPH_FILE_PATH="/app/supergraph.graphql" \
-v ./bench/supergraph.graphql:/app/supergraph.graphql \
${{ env.DOCKER_IMAGE_NAME }}@${{ needs.docker.outputs.docker_image_digest }}
sleep 5
- name: dump router logs
run: |
docker logs router
- name: test dummy request
run: |
TEST_RESPONSE=$(curl --fail -v -H "Content-Type: application/json" -d '{"query": "{ __typename }"}' http://localhost:4000/graphql)
echo $TEST_RESPONSE