Skip to content

Commit 2398fe8

Browse files
authoredMay 6, 2022
Repo infra overhaul (#2613)
* Switch to changesets for releases * Update repo to use npm workspaces * Update repo node / npm version * Use volta for local dev and CI node version mgmt. * Modernize and simplify CI steps
1 parent 77dc949 commit 2398fe8

File tree

20 files changed

+10972
-20293
lines changed

20 files changed

+10972
-20293
lines changed
 

‎.changeset/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

‎.changeset/config.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@1.6.3/schema.json",
3+
"changelog": [
4+
"@changesets/changelog-github",
5+
{ "repo": "apollographql/apollo-tooling" }
6+
],
7+
"commit": false,
8+
"linked": [],
9+
"access": "restricted",
10+
"baseBranch": "master",
11+
"updateInternalDependencies": "patch",
12+
"ignore": []
13+
}

‎.circleci/config.yml

+49-200
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,63 @@
11
version: 2.1
22

3-
# These "CircleCI Orbs" are reusable bits of configuration that can be shared
4-
# across projects. See https://circleci.com/orbs/ for more information.
53
orbs:
6-
# `oss` is a local reference to the package. The source for Apollo Orbs can
7-
# be found at http://github.com/apollographql/CircleCI-Orbs.
8-
oss: apollo/oss-ci-cd-tooling@0.0.20
9-
# win is a windows orb provided by circleci
10-
win: circleci/windows@2.4.1
4+
node: circleci/node@5.0.2
115

126
commands:
13-
# These are the steps used for each version of Node which we're testing
14-
# against. Thanks to YAMLs inability to merge arrays (though it is able
15-
# to merge objects), every version of Node must use the exact same steps,
16-
# or these steps would need to be repeated in a version of Node that needs
17-
# something different. Probably best to avoid that, out of principle, though.
18-
common_test_steps:
19-
description: Commands to run on every Node.js environment
7+
install-volta:
8+
description: Install volta to manage Node/npm versions
209
steps:
21-
- oss/install_specific_npm_version:
22-
version: '7'
23-
- checkout
24-
- oss/npm_clean_install_with_caching
25-
- run: npm run circle
26-
27-
# Important! When adding a new job to `jobs`, make sure to define when it
28-
# executes by also adding it to the `workflows` section below!
29-
jobs:
30-
# Platform tests, each with the same tests but different platform or version.
31-
NodeJS 12:
32-
docker:
33-
- image: cimg/node:12.22.8
34-
steps:
35-
- common_test_steps
36-
37-
NodeJS 14 Windows:
38-
executor:
39-
name: win/default
40-
environment:
41-
# Note: This is a no-op at the second, but bear with me on this. If this
42-
# comment is not removed by 2021-06-30 remove it along with the next line.
43-
# renovate: datasource=github-tags depName=nodejs/node versioning=node
44-
NODE_VERSION: 14.17.5
45-
NPM_VERSION: 7.10.0
46-
steps:
47-
- run: git config --global core.autocrlf false
4810
- run:
49-
name: Install desired Node.js version with nvm
11+
name: Install volta
12+
# Teach the volta installer to update Circle's special env
13+
# file instead of the default.
5014
command: |
51-
nvm install ${Env:NODE_VERSION}
52-
nvm on
53-
- run:
54-
# https://github.com/coreybutler/nvm-windows/issues/300
55-
# Have to move the command out of the way because it can't
56-
# overwrite itself otherwise. This is madness, but apparently
57-
# accepted. Other things I tried: using yarn to install npm,
58-
# using http://npm.im/npm-windows-upgrade and even shouting.
59-
name: Install specific version of npm in a crazy Windows way
60-
command: |
61-
$node_dir = (get-item (get-command npm).source).directory.fullname
62-
foreach ($cmd in @("npm", "npx")) {
63-
foreach ($ext in @(".ps1", ".cmd", "")) {
64-
if (Test-Path "$node_dir/$cmd$ext") {
65-
rename-item -path (join-path -path $node_dir -childpath "$cmd$ext") "${cmd}-orig${ext}"
66-
}
67-
}
68-
}
69-
npm-orig install --global "npm@${Env:NPM_VERSION}"
70-
- run:
71-
name: Assert Node.js version
72-
command: |
73-
if ((node --version) -Ne "v${Env:NODE_VERSION}") { exit 1 }
74-
- run:
75-
name: Assert npm version
76-
command: |
77-
if ((npm --version) -Ne "${Env:NPM_VERSION}") { exit 1 }
78-
- checkout
79-
- oss/npm_clean_install_with_caching
80-
- run: npm run circle
15+
curl https://get.volta.sh | PROFILE="$BASH_ENV" bash
8116
82-
NodeJS 14:
83-
docker:
84-
- image: cimg/node:14.18.2
17+
setup-node:
18+
parameters:
19+
node-version:
20+
type: string
21+
default: ""
8522
steps:
86-
- common_test_steps
87-
# We will save the results of this one particular invocation to use in
88-
# the publish step. Not only does this make the publishing step take less
89-
# time, this also ensures that a passing version gets deployed even if,
90-
# theoretically, rebuilding the same commit on the same version of
91-
# Node.js should yield the same results!
92-
- persist_to_workspace:
93-
root: .
94-
paths:
95-
- ./**
96-
97-
NodeJS 16:
98-
docker:
99-
- image: cimg/node:16.13.1
100-
steps:
101-
- common_test_steps
23+
- install-volta
24+
- checkout
25+
- when:
26+
condition: << parameters.node-version >>
27+
steps:
28+
- run: volta pin node@<< parameters.node-version >>
29+
- run: node --version
30+
- run: npm --version
31+
- node/install-packages
10232

103-
Publish GitHub Release:
33+
jobs:
34+
NodeJS:
35+
parameters:
36+
node-version:
37+
type: string
10438
docker:
105-
- image: cimg/go:1.17.8
39+
- image: cimg/base:stable
10640
steps:
107-
- attach_workspace:
108-
# Must be absolute path or relative path from working_directory
109-
at: .
110-
- run:
111-
name: "Publish Release on GitHub"
112-
command: |
113-
set +e
114-
test -d oclif-dist/channels && exit 1 || echo "Not a pre-release, continuing with publishing"
115-
/usr/local/go/bin/go get github.com/tcnksm/ghr
116-
VERSION=$(ls oclif-dist | cut -d 'v' -f2)
117-
echo "Publishing apollo@${VERSION} to GitHub Releases using ghr"
118-
ls ./oclif-dist/apollo-v${VERSION}/
119-
ghr -t ${GH_TOKEN} -c ${CIRCLE_SHA1} -delete apollo@${VERSION} "./oclif-dist/apollo-v${VERSION}/"
41+
- setup-node:
42+
node-version: <<parameters.node-version>>
43+
- run: npm run test:ci
44+
- store_test_results:
45+
path: junit.xml
12046

12147
# Other tests, unrelated to typical code tests.
12248
Linting:
12349
docker:
124-
- image: cimg/node:12.22.8
50+
- image: cimg/base:stable
12551
steps:
126-
- oss/install_specific_npm_version:
127-
version: '7'
128-
- checkout
129-
# (speed) --ignore-scripts to skip unnecessary Lerna build during linting.
130-
- run: npm install --ignore-scripts
52+
- setup-node
13153
- run: npm run lint
13254

13355
Query Check:
13456
docker:
135-
- image: cimg/node:12.22.8
57+
- image: cimg/base:stable
13658
steps:
137-
- oss/install_specific_npm_version:
138-
version: '7'
139-
- checkout
140-
- oss/npm_clean_install_with_caching
59+
- setup-node
14160
- run:
142-
name:
14361
command: |
14462
if [ -z "$CHECKS_API_KEY" ]; then
14563
echo "NO CHECKS_API_KEY! CANNOT RUN! This is normal on PRs from Forks."
@@ -149,12 +67,9 @@ jobs:
14967
15068
Generated Types Check:
15169
docker:
152-
- image: cimg/node:12.22.8
70+
- image: cimg/base:stable
15371
steps:
154-
- oss/install_specific_npm_version:
155-
version: '7'
156-
- checkout
157-
- oss/npm_clean_install_with_caching
72+
- setup-node
15873
- run:
15974
name: Generate types locally and compare type files
16075
command: |
@@ -165,84 +80,18 @@ jobs:
16580
npx apollo client:codegen --key=$CHECKS_API_KEY --outputFlat --target=typescript currentTypes.ts
16681
cmp --silent currentTypes.ts ./packages/apollo-language-server/src/graphqlTypes.ts || (echo "Type check failed. Run 'npm run client:codegen'" && exit 1)
16782
168-
common_non_publish_filters: &common_non_publish_filters
169-
filters:
170-
# Ensure every job has `tags` filters since the publish steps have tags.
171-
# This is some wild configuration thing that's pretty hard to figure out.
172-
tags:
173-
only: /.*/
174-
175-
common_publish_filters: &common_publish_filters
176-
filters:
177-
# Only run pre-publish and publish steps on specific tags.
178-
tags:
179-
only: /^publish\/[0-9]+$/
180-
# We want the publish to trigger on the above tag, not any branch.
181-
branches:
182-
ignore: /.*/
183-
18483
workflows:
18584
version: 2
18685
Build:
18786
jobs:
188-
- NodeJS 12:
189-
<<: *common_non_publish_filters
190-
#- NodeJS 14 Windows:
191-
# <<: *common_non_publish_filters
192-
- NodeJS 14:
193-
<<: *common_non_publish_filters
194-
- NodeJS 16:
195-
<<: *common_non_publish_filters
196-
- Linting:
197-
<<: *common_non_publish_filters
198-
- Query Check:
199-
<<: *common_non_publish_filters
200-
- Generated Types Check:
201-
<<: *common_non_publish_filters
202-
- oss/oclif_pack_from_verdaccio_storage:
203-
name: Build CLI
204-
package: apollo
205-
<<: *common_non_publish_filters
206-
requires:
207-
- Package tarballs
208-
- oss/lerna_tarballs:
209-
name: Package tarballs
210-
<<: *common_non_publish_filters
211-
requires:
212-
- NodeJS 12
213-
#- NodeJS 14 Windows
214-
- NodeJS 14
215-
- NodeJS 16
216-
- Publish GitHub Release:
217-
<<: *common_publish_filters
218-
requires:
219-
- Confirmation
220-
- Build CLI
221-
- oss/dry_run:
222-
name: Dry-run
223-
<<: *common_publish_filters
224-
requires:
225-
- NodeJS 12
226-
#- NodeJS 14 Windows
227-
- NodeJS 14
228-
- NodeJS 16
229-
- Build CLI
230-
- oss/confirmation:
231-
name: Confirmation
232-
type: approval
233-
<<: *common_publish_filters
234-
requires:
235-
- Dry-run
236-
- Build CLI
237-
- oss/publish:
238-
name: Publish
239-
<<: *common_publish_filters
240-
requires:
241-
- Confirmation
242-
# This "Dry-run" is also gated behind "Confirmation", but being left here
243-
# as a dependency in case "Confirmation" is ever removed from this workflow
244-
# so we have a clear picture of the actual dependency (as multiple go through
245-
# the Confirmation step).
246-
- Dry-run
247-
248-
87+
- NodeJS:
88+
name: NodeJS << matrix.node-version >>
89+
matrix:
90+
parameters:
91+
node-version:
92+
- "12"
93+
- "14"
94+
- "16"
95+
- Linting
96+
- Query Check
97+
- Generated Types Check

‎.codesandbox/ci.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"sandboxes": [],
3-
"node": "16"
3+
"node": "16",
4+
"installCommand": "install-with-npm-8.5"
45
}

‎.envrc

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export VOLTA_HOME="$PWD/.volta"
2+
PATH_add "$VOLTA_HOME/bin"
3+
4+
if ! [ -f "$VOLTA_HOME/bin/volta" ]; then
5+
echo "Volta not found in $VOLTA_HOME/bin/volta, installing..."
6+
curl https://get.volta.sh/ | bash
7+
fi
8+
9+
# Allow you to run jest and other things in node_modules/.bin without npx.
10+
layout node

‎.github/workflows/release-pr.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
release:
10+
name: Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout Repo
14+
uses: actions/checkout@v2
15+
with:
16+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
17+
fetch-depth: 0
18+
19+
- name: Setup Node.js 16.x
20+
uses: actions/setup-node@v2
21+
with:
22+
node-version: 16.x
23+
24+
- name: Ensure npm version 8.5.0
25+
run: npm i -g npm@8.5.0
26+
- name: Install Dependencies
27+
run: npm i
28+
29+
- name: Create Release Pull Request / NPM Publish
30+
uses: changesets/action@v1
31+
with:
32+
publish: npm run changeset-publish
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

‎.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ packages/*/package-lock.json
1818

1919
.DS_Store
2020

21-
lerna-debug.log
22-
2321
.env
2422

2523
# files generated from tests
@@ -28,3 +26,6 @@ __tmp__*
2826

2927
#idea folder
3028
.idea/
29+
30+
# volta files installed within the project if using direnv
31+
.volta

0 commit comments

Comments
 (0)
Please sign in to comment.