Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bazel remote caching #3

Merged
merged 48 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
c012f00
Bazel remote caching
Zemnmez Sep 21, 2023
7ad9c00
Merge branch 'main' into remote-cache
Zemnmez Oct 1, 2023
343802f
update bazel_rce code to github org monorepo
Zemnmez Oct 2, 2023
bd75a12
Merge branch 'remote-cache' of https://github.com/zemn-me/monorepo in…
Zemnmez Oct 2, 2023
4f5cb7f
set GITHUB_TOKEN for pulumi access
Zemnmez Oct 2, 2023
321dee6
use fullName with actions secret
Zemnmez Oct 2, 2023
bdcb759
the api is annoying. so we are doing this instead
Zemnmez Oct 2, 2023
486954d
fix for https://github.com/pulumi/pulumi-github/issues/248
Zemnmez Oct 2, 2023
294e499
crazy hack that just might work to fix https://github.com/pulumi/pulu…
Zemnmez Oct 2, 2023
bc2b31e
add new access token and create staging secret
Zemnmez Oct 3, 2023
5baf17f
oops
Zemnmez Oct 3, 2023
1464ca5
fix formatting
Zemnmez Oct 3, 2023
176579e
just a minor push to force a redeploy
Zemnmez Oct 4, 2023
2e949b3
expose ALB directly to the internet
Zemnmez Oct 4, 2023
3718479
write the dockerfile instead of just trying to send its text
Zemnmez Oct 4, 2023
0618335
public IP
Zemnmez Oct 4, 2023
0d1649c
correct ports
Zemnmez Oct 4, 2023
4b9cee3
try to correct ports
Zemnmez Oct 4, 2023
4e49851
try to fix 443 error...
Zemnmez Oct 4, 2023
3dc275d
giving up for the night. i might have to implement this awsx feature …
Zemnmez Oct 4, 2023
2819a6a
many changes
Zemnmez Oct 5, 2023
6d58b37
I hope this counts as progress
Zemnmez Oct 5, 2023
c7c6a75
currently there is a problem where the fargate compute units cannot a…
Zemnmez Oct 5, 2023
e63208c
try to automagically get a gateway set up. also i need to fix pulumi …
Zemnmez Oct 5, 2023
6320bcc
Try to see if we can use the correct repo name again.
Zemnmez Oct 22, 2023
bfa38a8
Try to test if the GitHub credentials are incorrect.
Zemnmez Oct 22, 2023
c3d683e
Change error to warning for Pulumi testing.
Zemnmez Oct 22, 2023
a7ce7d2
Attempt to fix Pulumi dependency issue by upgrading deps.
Zemnmez Oct 22, 2023
8fb8822
- Add @aws-sdk/region-config-resolver (pulumi was complaining
Zemnmez Oct 22, 2023
2af0098
upgrade aws-sdk in an attempt to get @aws-sdk/region-config-resolver …
Zemnmez Oct 22, 2023
f38a22e
Manually add transient peer @aws-sdk/region-config-resolver
Zemnmez Oct 22, 2023
0ff76b5
fix build in ts/pulumi/...
Zemnmez Oct 23, 2023
faa6dda
remove code that didnt do anything
Zemnmez Oct 23, 2023
3e33aaf
progress
Zemnmez Oct 23, 2023
a8b3ac1
progress
Zemnmez Oct 23, 2023
5e63cbc
fix alb name
Zemnmez Oct 23, 2023
2e3439c
fix missed parent
Zemnmez Oct 23, 2023
a16092b
fixes
Zemnmez Oct 23, 2023
1fa216b
move listener out of awsx/alb -- couldnt work out how to correctly sp…
Zemnmez Oct 23, 2023
1e52705
instruct the Fargate service to wait on the internet gateway and nat …
Zemnmez Oct 23, 2023
7513675
follow aws provided example better https://github.com/aws-samples/con…
Zemnmez Oct 23, 2023
ddfd62e
re introduce ../ to see if we can make the bastard Actions secret.'
Zemnmez Oct 23, 2023
cc4a36a
Remove the insanely expensive NAT gateway and test for missing
Zemnmez Oct 23, 2023
fc21db9
remove presubmit requirement for staging
Zemnmez Oct 23, 2023
86d784d
- provide GITHUB_TOKEN to Staging (oops)
Zemnmez Oct 24, 2023
dc9133c
try one last time to see if I can meddle with the repo name to get th…
Zemnmez Oct 24, 2023
2b97cbe
see if removing GITHUB_OWNER will make pulumi / tf happier
Zemnmez Oct 24, 2023
40970be
I think this should finally fix the issues...
Zemnmez Oct 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/bootstrap_bazel_remote_cache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /usr/bin/env bash

echo "::group::Configure Bazel Remote Cache"

Check warning on line 3 in .github/workflows/bootstrap_bazel_remote_cache.sh

View workflow job for this annotation

GitHub Actions / Presubmit

Running without bazel cache!

BAZEL_REMOTE_CACHE_URL was not specified, so tests will be doing all the work from scratch.

Check warning on line 3 in .github/workflows/bootstrap_bazel_remote_cache.sh

View workflow job for this annotation

GitHub Actions / Staging

Running without bazel cache!

BAZEL_REMOTE_CACHE_URL was not specified, so tests will be doing all the work from scratch.

if [[ -z "${BAZEL_REMOTE_CACHE_URL}" ]]; then
echo "::warning file=.github/workflows/bootstrap_bazel_remote_cache.sh,line=3,endLine=3,title=Running without bazel cache!:: BAZEL_REMOTE_CACHE_URL was not specified, so tests will be doing all the work from scratch."
else
echo "Using bazel remote cache."
echo "build --remote_cache=${BAZEL_REMOTE_CACHE_URL}" > .bazelrc
echo "test --remote_cache=${BAZEL_REMOTE_CACHE_URL}" > .bazelrc
fi

echo "::endgroup::"

exit 0
75 changes: 21 additions & 54 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,12 @@ jobs:
large-packages: false
- name: Checkout code
uses: actions/checkout@v3
# example copied from:
# https://github.com/actions/cache/blob/04f198bf0b2a39f7230a4304bf07747a0bddf146/examples.md
- name: Cache Bazel
uses: actions/cache@v3
with:
path: |
~/.cache/bazel
key: >
${{ runner.os }}-bazel-${{
hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE',
'WORKSPACE.bazel', 'MODULE.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-
- name: Presubmit
run: |
./.github/workflows/bootstrap_bazel_remote_cache.sh
bazel run //ci:presubmit -- --skip-pulumi-deploy
env:
BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }}
Staging:
# Pulumi doesn't like it when multiple deploys are attempted at once.
# This is also enforced at the pulumi layer, but i'm sure github actions
Expand All @@ -123,7 +113,9 @@ jobs:
|| github.event_name == 'workflow_dispatch'

# Performs all offline testing.
needs: Presubmit
# remove (maybe temporarily?) the presubmit requirement for this
# to speed up testing the cache.
# needs: Presubmit
runs-on: ubuntu-latest
steps:
- name: Free Disk Space (Ubuntu)
Expand All @@ -135,19 +127,6 @@ jobs:
docker-images: true
large-packages: false
swap-storage: true
# example copied from:
# https://github.com/actions/cache/blob/04f198bf0b2a39f7230a4304bf07747a0bddf146/examples.md
- name: Cache Bazel
uses: actions/cache@v3
with:
path: |
~/.cache/bazel
key: >
${{ runner.os }}-bazel-${{
hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE',
'WORKSPACE.bazel', 'MODULE.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-
# in order to determine if applying this patch would succeed
# *on the mainline branch*
# we have to set the Pulumi state to be the same.
Expand All @@ -163,19 +142,26 @@ jobs:
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# https://github.com/pulumi/pulumi-github/issues/248
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_SECRET }}
GITHUB_TOKEN: ${{ secrets.GH_PAT_SECRETS_CREATOR }}
BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }}
- name: Switch back to candidate branch
uses: actions/checkout@v3
- name: Deploy candidate branch to Staging
# we can run this dirty since the next run will --overwrite anyway
run: |
./.github/workflows/bootstrap_bazel_remote_cache.sh
bazel run //ci:presubmit -- \
--skip-bazel-tests \
--dangerously-skip-pnpm-lockfile-validation --dirty
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# https://github.com/pulumi/pulumi-github/issues/248
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_SECRET }}
GITHUB_TOKEN: ${{ secrets.GH_PAT_SECRETS_CREATOR }}
BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }}
Submit:
concurrency: pulumi_production
if: github.event_name == 'push'
Expand All @@ -193,31 +179,22 @@ jobs:
large-packages: false
- name: Checkout code
uses: actions/checkout@v3
# example copied from:
# https://github.com/actions/cache/blob/04f198bf0b2a39f7230a4304bf07747a0bddf146/examples.md
- name: Cache Bazel
uses: actions/cache@v3
with:
path: |
~/.cache/bazel
key: >
${{ runner.os }}-bazel-${{
hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE',
'WORKSPACE.bazel', 'MODULE.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-
- name: Submit
# Use npx to try to generate only
# bazel generated node_modules
run: |
./.github/workflows/bootstrap_bazel_remote_cache.sh
bazel run //ci:submit
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# https://github.com/pulumi/pulumi-github/issues/248
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_SECRET }}
GITHUB_TOKEN: ${{ secrets.GH_PAT_SECRETS_CREATOR }}
BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }}

Postsubmit:
runs-on: ubuntu-latest
if: github.event_name == 'push'
Expand All @@ -234,26 +211,16 @@ jobs:
swap-storage: true
- name: Checkout code
uses: actions/checkout@v3
# example copied from:
# https://github.com/actions/cache/blob/04f198bf0b2a39f7230a4304bf07747a0bddf146/examples.md
- name: Cache Bazel
uses: actions/cache@v3
with:
path: |
~/.cache/bazel
key: >
${{ runner.os }}-bazel-${{
hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE',
'WORKSPACE.bazel', 'MODULE.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-
- name: Postsubmit
run: |
./.github/workflows/bootstrap_bazel_remote_cache.sh
bazel run //ci:postsubmit
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# https://github.com/pulumi/pulumi-github/issues/248
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_SECRET }}
BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }}
34 changes: 33 additions & 1 deletion ci/presubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,39 @@ const cmd = new Command('presubmit')
}
});

function logError(e: unknown) {
if (!(e instanceof Error)) return console.log(e);

const stack = e.stack ?? Error.prototype.stack;

if (!stack) return console.log(e);

const runfilesRoot = process.env['TEST_SRCDIR'];

if (!runfilesRoot) return console.log(e);

const runfilesRootIndex = stack.indexOf(runfilesRoot);

if (runfilesRootIndex == -1) return console.log(e);

const suffix = stack.slice(runfilesRootIndex + runfilesRoot.length);

const res = /^([A-Za-z0-9/._]+)\.(?:ts|js):(\d+):(\d+)/.exec(suffix);

if (res === null) return console.log(e);

const [, filePrefix, line, offset] = res;

console.error(
WorkflowCommand('error')({
file: filePrefix,
line: line,
col: offset,
})('' + e)
);
}

cmd.parseAsync(process.argv).catch(e => {
process.exitCode = 2;
console.error(e);
logError(e);
});
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"@fortawesome/react-fontawesome": "0.2.0",
"@microsoft/api-documenter": "7.22.33",
"@microsoft/api-extractor": "7.36.4",
"@pulumi/aws": "6.0.4",
"@pulumi/awsx": "1.0.5",
"@pulumi/aws": "6.6.0",
"@pulumi/awsx": "2.0.2",
"@pulumi/pulumi": "3.81.0",
"@schemastore/package": "0.0.10",
"@swc/cli": "0.1.62",
Expand Down Expand Up @@ -103,10 +103,14 @@
"pnpm": "npm run -- bazel run -- @pnpm//:pnpm --dir $PWD"
},
"dependencies": {
"@aws-sdk/region-config-resolver": "^3.433.0",
"@commander-js/extra-typings": "^11.0.0",
"@pulumi/command": "4.5.0",
"@pulumi/github": "^5.17.0",
"@pulumi/random": "^4.13.4",
"@react-spring/rafz": "^9.7.3",
"@types/bcryptjs": "2.4.3",
"aws-sdk": "^2.1478.0",
"csstype": "^3.1.1",
"devtools-protocol": "^0.0.1193409",
"eslint-mdx": "^2.1.0",
Expand Down
Loading