Skip to content

Commit

Permalink
Update Oclif and test tarballs (#2378)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkisiela authored Jun 27, 2023
1 parent 7599e98 commit 05b37a8
Show file tree
Hide file tree
Showing 29 changed files with 740 additions and 269 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-doors-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-hive/cli': minor
---

Support HIVE_AUTHOR and HIVE_COMMIT env vars
5 changes: 5 additions & 0 deletions .changeset/forty-plants-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-hive/cli': patch
---

Adds windows installer
15 changes: 3 additions & 12 deletions .github/workflows/graphql-schema-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,14 @@ jobs:
with:
fetch-depth: 2

- name: setup environment
uses: ./.github/actions/setup
with:
actor: graphql-schema-check

- name: check pull request label
if: contains(github.event.pull_request.labels.*.name, 'non-breaking')
run: echo "safeFlag=--forceSafe" >> $GITHUB_OUTPUT
id: pr-label-check

- name: build core package
run: pnpm build --filter @graphql-hive/core

- name: schema check
env:
HIVE_TOKEN: ${{ secrets.hiveToken }}
run:
./packages/libraries/cli/bin/dev schema:check
"packages/services/api/src/modules/*/module.graphql.ts" ${{
steps.pr-label-check.outputs.safeFlag }} --github
run: |
curl -sSL https://graphql-hive.com/install.sh | sh
hive schema:check "packages/services/api/src/modules/*/module.graphql.ts" ${{steps.pr-label-check.outputs.safeFlag }} --github
14 changes: 3 additions & 11 deletions .github/workflows/graphql-schema-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,9 @@ jobs:
with:
fetch-depth: 2

- name: setup environment
uses: ./.github/actions/setup
with:
actor: graphql-schema-publish

- name: build core package
run: pnpm build --filter @graphql-hive/core

- name: schema publish
env:
HIVE_TOKEN: ${{ secrets.hiveToken }}
run:
./packages/libraries/cli/bin/dev schema:publish
"packages/services/api/src/modules/*/module.graphql.ts" --force --github
run: |
curl -sSL https://graphql-hive.com/install.sh | sh
hive schema:publish "packages/services/api/src/modules/*/module.graphql.ts" --github
11 changes: 2 additions & 9 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,9 @@ jobs:

# Release alpha version on NPM for Hive libraries
alpha:
uses: the-guild-org/shared-config/.github/workflows/release-snapshot.yml@main
uses: ./.github/workflows/release-alpha.yaml
if: ${{ github.event.pull_request.title != 'Upcoming Release Changes' }}
with:
npmTag: alpha
buildScript: build:libraries
nodeVersion: 18
packageManager: pnpm
secrets:
githubToken: ${{ secrets.GITHUB_TOKEN }}
npmToken: ${{ secrets.NPM_TOKEN }}
secrets: inherit

# Release RC version on NPM for Hive libraries
release-candidate:
Expand Down
119 changes: 119 additions & 0 deletions .github/workflows/release-alpha.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
on:
workflow_call:

jobs:
# Release alpha version on NPM for Hive libraries
npm:
uses: the-guild-org/shared-config/.github/workflows/release-snapshot.yml@main
with:
npmTag: alpha
buildScript: build:libraries
nodeVersion: 18
packageManager: pnpm
secrets:
githubToken: ${{ secrets.GITHUB_TOKEN }}
npmToken: ${{ secrets.NPM_TOKEN }}

# Upload zipped tarballs to GitHub
cli-artifacts:
runs-on: ubuntu-22.04

steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: setup environment
uses: ./.github/actions/setup
with:
codegen: false # no need to run because release script will run it anyway
actor: release-alpha

- name: build libraries
run: pnpm build:libraries

# Needed for `oclif pack win`
- name: Install NSIS
run: |
sudo apt-get -y install nsis
- name: pack tarballs
working-directory: packages/libraries/cli
run: pnpm oclif:pack

- name: upload darwin arm64
uses: actions/upload-artifact@v3
with:
name: hive-cli-darwin-arm64
path: ./packages/libraries/cli/dist/*-darwin-arm64.tar.gz

- name: upload darwin x64
uses: actions/upload-artifact@v3
with:
name: hive-cli-darwin-x64
path: ./packages/libraries/cli/dist/*-darwin-x64.tar.gz

- name: upload windows x64
uses: actions/upload-artifact@v3
with:
name: hive-cli-windows-x64
path: ./packages/libraries/cli/dist/win32/*-x64.exe

- name: upload windows x86
uses: actions/upload-artifact@v3
with:
name: hive-cli-windows-x86
path: ./packages/libraries/cli/dist/win32/*-x86.exe

- name: upload linux arm
uses: actions/upload-artifact@v3
with:
name: hive-cli-linux-arm
path: ./packages/libraries/cli/dist/*-linux-arm.tar.gz

- name: upload linux x64
uses: actions/upload-artifact@v3
with:
name: hive-cli-linux-x64
path: ./packages/libraries/cli/dist/*-linux-x64.tar.gz

cli-test:
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
needs: [cli-artifacts]
steps:
- name: Pull artifact for macos
if: matrix.os == 'macos-latest'
uses: actions/download-artifact@v3
with:
name: hive-cli-darwin-x64

- name: Pull artifact for ubuntu
if: matrix.os == 'ubuntu-latest'
uses: actions/download-artifact@v3
with:
name: hive-cli-linux-x64

- name: Pull artifact for windows
if: matrix.os == 'windows-latest'
uses: actions/download-artifact@v3
with:
name: hive-cli-windows-x64

- name: Unzip and run
run: |
rm -rf /usr/local/bin/node
rm -rf /usr/local/lib/node
if command -v node &> /dev/null
then
echo "Expected node to not be installed"
command -v node
exit 1
fi
tar -xzf *.tar.gz
# Expect the command to succeed
./hive/bin/hive --version || exit 1
9 changes: 7 additions & 2 deletions .github/workflows/release-stable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ jobs:
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "publish=true" >> $GITHUB_OUTPUT
# Needed for `oclif pack win`
- name: Install NSIS
run: |
sudo apt-get -y install nsis
- name: pack tarballs
if: steps.cli.outputs.publish == 'true'
working-directory: packages/libraries/cli
Expand All @@ -65,5 +70,5 @@ jobs:
env:
VERSION: ${{ steps.cli.outputs.version }}
run:
pnpm oclif promote --no-xz --sha ${GITHUB_SHA:0:7} --version $VERSION || pnpm oclif
promote --no-xz --sha ${GITHUB_SHA:0:8} --version $VERSION
pnpm oclif promote --no-xz --sha ${GITHUB_SHA:0:7} --version $VERSION --win || pnpm oclif
promote --no-xz --sha ${GITHUB_SHA:0:8} --version $VERSION --win
20 changes: 20 additions & 0 deletions docker/cli.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:18.16.0-slim

WORKDIR /usr/src/app
COPY . /usr/src/app/

RUN npm install --omit=dev
RUN npm install -g file:./

LABEL org.opencontainers.image.title=$IMAGE_TITLE
LABEL org.opencontainers.image.version=$RELEASE
LABEL org.opencontainers.image.description=$IMAGE_DESCRIPTION
LABEL org.opencontainers.image.authors="The Guild"
LABEL org.opencontainers.image.vendor="Kamil Kisiela"
LABEL org.opencontainers.image.url="https://github.com/kamilkisiela/graphql-hive"

ENV ENVIRONMENT production
ENV RELEASE $RELEASE
RUN npx hive --version

ENTRYPOINT ["npx", "hive"]
31 changes: 30 additions & 1 deletion docker/docker.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ target "router-base" {
}
}

target "cli-base" {
dockerfile = "${PWD}/docker/cli.dockerfile"
args = {
RELEASE = "${RELEASE}"
}
}

target "target-dev" {}

target "target-ci" {
Expand Down Expand Up @@ -343,6 +350,21 @@ target "apollo-router" {
]
}

target "cli" {
inherits = ["cli-base", get_target()]
context = "${PWD}/packages/libraries/cli"
args = {
IMAGE_TITLE = "graphql-hive/cli"
IMAGE_DESCRIPTION = "GraphQL Hive CLI"
}
tags = [
local_image_tag("cli"),
stable_image_tag("cli"),
image_tag("cli", COMMIT_SHA),
image_tag("cli", BRANCH_NAME)
]
}

group "build" {
targets = [
"emails",
Expand All @@ -358,7 +380,8 @@ group "build" {
"server",
"stripe-billing",
"composition-federation-2",
"app"
"app",
"cli"
]
}

Expand All @@ -384,3 +407,9 @@ group "rust" {
"apollo-router"
]
}

group "cli" {
targets = [
"cli"
]
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@
"patchedDependencies": {
"@theguild/buddy@0.1.0": "patches/@theguild__buddy@0.1.0.patch",
"mjml-core@4.14.0": "patches/mjml-core@4.14.0.patch",
"@oclif/core@1.23.0": "patches/@oclif__core@1.23.0.patch",
"oclif@3.9.1": "patches/oclif@3.9.1.patch",
"@slonik/migrator@0.11.3": "patches/@slonik__migrator@0.11.3.patch",
"@apollo/federation@0.38.1": "patches/@apollo__federation@0.38.1.patch",
"@octokit/webhooks-methods@3.0.1": "patches/@octokit__webhooks-methods@3.0.1.patch",
"bullmq@3.15.8": "patches/bullmq@3.15.8.patch",
"@theguild/editor@1.2.5": "patches/@theguild__editor@1.2.5.patch",
"eslint@8.43.0": "patches/eslint@8.43.0.patch",
"@graphql-eslint/eslint-plugin@3.19.1": "patches/@graphql-eslint__eslint-plugin@3.19.1.patch"
"@graphql-eslint/eslint-plugin@3.19.1": "patches/@graphql-eslint__eslint-plugin@3.19.1.patch",
"@oclif/core@2.8.5": "patches/@oclif__core@2.8.5.patch"
}
}
}
2 changes: 2 additions & 0 deletions packages/libraries/cli/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
hive.json
Loading

0 comments on commit 05b37a8

Please sign in to comment.