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

DOP-4127: Monorepo builds without Makefiles #938

Merged
merged 162 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
f4b5188
experiments, added nextGenParse call to jobHandler
mmeigs Nov 14, 2023
8f941ba
stage ecs - no makefiles
mmeigs Nov 14, 2023
706af67
alter snooty version
mmeigs Nov 14, 2023
1a63501
next gen html
mmeigs Nov 15, 2023
0be0b24
command key
mmeigs Nov 15, 2023
6c43e45
parse
mmeigs Nov 15, 2023
e733122
catch
mmeigs Nov 15, 2023
2442b6f
logger
mmeigs Nov 15, 2023
901a229
remove error
mmeigs Nov 15, 2023
9aa2fd2
more logging
mmeigs Nov 15, 2023
8bd6ade
cwd
mmeigs Nov 15, 2023
c11687b
repoDir correct
mmeigs Nov 15, 2023
68eed83
quotations
mmeigs Nov 15, 2023
e9d9b36
successful parse? odd address
mmeigs Nov 15, 2023
dc4c2a1
oas page build
mmeigs Nov 16, 2023
1873ce9
xlarge
mmeigs Nov 16, 2023
478ebf3
persistence module
mmeigs Nov 17, 2023
ab4f652
quote
mmeigs Nov 17, 2023
71751a4
no parse
mmeigs Nov 17, 2023
38c0f7d
try catch parse
mmeigs Nov 17, 2023
e313e5f
type error
mmeigs Nov 17, 2023
b97835c
no parse, use persistence and build
mmeigs Nov 20, 2023
97cbc8b
log errors
mmeigs Nov 20, 2023
2832b0e
localApp working
mmeigs Nov 20, 2023
1d45d72
remove /dist
mmeigs Nov 20, 2023
11bac2c
add build deps & nextgenhtml
mmeigs Nov 22, 2023
7aee7af
add logging to build deps
mmeigs Nov 22, 2023
afadedc
log html
mmeigs Nov 22, 2023
e320a67
remove build deps for envs
mmeigs Nov 22, 2023
178e680
env vars
mmeigs Nov 22, 2023
cf18066
build deps before executeBuild
mmeigs Nov 22, 2023
3bc4550
staging monorepo jobs
mmeigs Nov 27, 2023
781b7ab
comment
mmeigs Nov 27, 2023
bae5f35
localApp type cleanup
mmeigs Nov 27, 2023
53d68da
stage
mmeigs Nov 27, 2023
62a9747
deploy
mmeigs Nov 27, 2023
733211c
clean fs
mmeigs Nov 27, 2023
2f3bebd
status
mmeigs Nov 27, 2023
6b4dcbe
no event body
mmeigs Nov 27, 2023
56b11c7
throw new error
mmeigs Nov 27, 2023
9c97ae1
commented out all unnecessary steps
mmeigs Nov 28, 2023
4cb8bbb
explicitly call build steps
mmeigs Nov 28, 2023
f11e4b5
remove steps that should not be used
mmeigs Nov 28, 2023
c3ae28e
include job inqueue for error
mmeigs Nov 28, 2023
e352d0b
Merge branch 'master' into DOP-4127-no-makefiles
mmeigs Nov 28, 2023
b576633
log status
mmeigs Nov 28, 2023
c099d3b
Empty-Commit
mmeigs Nov 29, 2023
a2e9a64
comment
mmeigs Nov 29, 2023
02aba79
used process.env to find URL and BUCKET
mmeigs Nov 29, 2023
7a10135
save localApp
mmeigs Nov 29, 2023
9e36e45
uncomment prepNextGenBuild
mmeigs Nov 29, 2023
504cb84
remove throw error
mmeigs Nov 29, 2023
0c8de69
not build on preprd
mmeigs Nov 29, 2023
62adea1
Merge branch 'master' into DOP-4127-no-makefiles
mmeigs Nov 29, 2023
86dbf92
buildCommands array
mmeigs Nov 29, 2023
857a1db
log publish
mmeigs Nov 29, 2023
d87b56e
use normal deploy
mmeigs Nov 29, 2023
cb8080e
deploy
mmeigs Nov 29, 2023
01463ff
add cp commands
mmeigs Nov 29, 2023
0a2c7b5
cd snooty
mmeigs Nov 29, 2023
c0717cf
log outputs
mmeigs Nov 29, 2023
02b61af
ref repoDir rather than cwd
mmeigs Nov 29, 2023
a3cbc72
correct reposDir vs repoDir
mmeigs Nov 29, 2023
7d0ba08
add slash
mmeigs Nov 29, 2023
375a97d
add repos to prodFileName
mmeigs Nov 29, 2023
482f841
log build deps
mmeigs Nov 30, 2023
9f82e55
change prodFIleName to cwd/snooty
mmeigs Nov 30, 2023
93fbc40
run parse
mmeigs Nov 30, 2023
68137c4
remove deploy
mmeigs Nov 30, 2023
be0d0a0
merged latest master
mmeigs Nov 30, 2023
c386506
override build in stagingJobHandler
mmeigs Nov 30, 2023
6534d77
override build, set up debugger
mmeigs Nov 30, 2023
d86040f
vscode launch
mmeigs Nov 30, 2023
fe4ddca
remove dist
mmeigs Dec 1, 2023
8d7182f
remove dist
mmeigs Dec 1, 2023
312ba00
use project
mmeigs Dec 4, 2023
3c7156d
readd build deps
mmeigs Dec 4, 2023
22d75fd
add cp and cd commands to nextGenHtml
mmeigs Dec 4, 2023
6ae841f
cp correct paths
mmeigs Dec 4, 2023
21207c7
remove first cp and cd
mmeigs Dec 4, 2023
e494c7f
remove cp
mmeigs Dec 4, 2023
8f48f51
ref snooty filepath correctly
mmeigs Dec 4, 2023
b87d85c
dockerfile snooty branch mm-log
mmeigs Dec 4, 2023
f1b6e57
remove first cp
mmeigs Dec 4, 2023
f48ac30
cd ..
mmeigs Dec 5, 2023
f24ef53
commands
mmeigs Dec 5, 2023
76a0677
stringify, logs
mmeigs Dec 5, 2023
901792c
use chdir
mmeigs Dec 5, 2023
5254b44
cp second
mmeigs Dec 5, 2023
09cc84a
log in clicommand
mmeigs Dec 5, 2023
94312e8
pass logger to mut publish
mmeigs Dec 5, 2023
f502182
dotcomstg -> stg
mmeigs Dec 5, 2023
52590c4
checkout and pull branch
mmeigs Dec 5, 2023
243ac89
add pull repo and change clone
mmeigs Dec 5, 2023
32496d4
commented out incorrect code
mmeigs Dec 5, 2023
b770001
local run works for both cloud-docs and monorepo/cloud-docs
mmeigs Dec 7, 2023
3667b5d
log event and boyd
mmeigs Dec 7, 2023
2650e8f
log out trigger build
mmeigs Dec 7, 2023
0108bc4
log repo name and feat flag
mmeigs Dec 7, 2023
150b11f
feature flag
mmeigs Dec 7, 2023
39d84b8
ssmprefix
mmeigs Dec 7, 2023
a249c26
env
mmeigs Dec 7, 2023
178a527
dist
mmeigs Dec 7, 2023
a6f3261
remove feature flag for feature branch build
mmeigs Dec 7, 2023
f0b535c
log why no paths
mmeigs Dec 7, 2023
045180b
change slash of path
mmeigs Dec 7, 2023
1d69643
clean
mmeigs Dec 7, 2023
7713c19
organize code
mmeigs Dec 8, 2023
c6c5c69
clean
mmeigs Dec 8, 2023
f796c4a
redoc
mmeigs Dec 8, 2023
ffbc331
Co-authored-by: Brandon Ly <[email protected]>
mmeigs Dec 8, 2023
39837b4
fixes from merge
mmeigs Dec 8, 2023
c3313a3
comment out builddeps, use redoc rc
mmeigs Dec 11, 2023
40e5c26
duplicate clone
mmeigs Dec 11, 2023
c25b533
clean, get bucket and url
mmeigs Dec 11, 2023
248df20
log env vars
mmeigs Dec 11, 2023
d23da3c
pass logger to getEnvVar
mmeigs Dec 11, 2023
c0c4c57
takeover preprd
mmeigs Dec 11, 2023
2adf502
add to v1?
mmeigs Dec 11, 2023
4c8d4c3
log which build
mmeigs Dec 11, 2023
64cf314
force directory
mmeigs Dec 11, 2023
07967fb
add directory to debug command and local build
mmeigs Dec 12, 2023
2a8386b
remove from preprd
mmeigs Dec 12, 2023
f5dbead
clean up
mmeigs Dec 12, 2023
07caee9
keep conditionals for buildCommands in normal build
mmeigs Dec 12, 2023
e45fce2
further cleaning
mmeigs Dec 12, 2023
5c558da
remove logs
mmeigs Dec 12, 2023
4ac7b01
number of logs
mmeigs Dec 12, 2023
b57f0ac
curl into repoDir/targetDir
mmeigs Dec 12, 2023
493edaa
try new flow of logging
mmeigs Dec 13, 2023
52b2f15
remove comments
mmeigs Dec 13, 2023
492d7c5
allow output and error text to be returned from nextGenStage
mmeigs Dec 13, 2023
7f3299d
clean logs
mmeigs Dec 14, 2023
b8dec8c
revert targetDir for downloadBuildDependencies
mmeigs Dec 14, 2023
bfe3cbd
clean, wrapWithBenchmark
mmeigs Dec 14, 2023
93d2642
Merge branch 'master' into DOP-4127-no-makefiles
mmeigs Dec 14, 2023
038337f
PR feedback
mmeigs Dec 15, 2023
211d1c2
[DOP-4127]: Update dockerfile.local to have redoc installed properly
branberry Dec 18, 2023
841e6f4
[DOP-4127]: Use new SQS queue URL
branberry Dec 18, 2023
033d58a
[DOP-4127]: Install redoc bundle
branberry Dec 18, 2023
1eaf867
[DOP-4127]: Revert how redoc is installed
branberry Dec 18, 2023
c4052bb
PR feedback, second round
mmeigs Dec 19, 2023
64e6af4
Merge branch 'master' into DOP-4127-no-makefiles
mmeigs Dec 19, 2023
d1367a7
replace useWithBenchmarks with isNextGen
mmeigs Dec 19, 2023
e16a789
source patchId from getBuildAndGetDependencies
mmeigs Dec 20, 2023
ffe258c
Merge branch 'master' into DOP-4127-no-makefiles
mmeigs Dec 20, 2023
58b7c14
[DOP-4204]: Update README for local Autobuilder (#954)
branberry Jan 2, 2024
f7d968f
added logging and error throwing in wrapWithBenchmark
mmeigs Jan 3, 2024
8e5e756
conditionally write patchId and commitHash env vars
mmeigs Jan 3, 2024
4a790f3
remove logger as parameter of wrapWithBenchmarks
mmeigs Jan 3, 2024
82f9024
[DOP-4127]: Update error logging and other misc changes
branberry Jan 3, 2024
99bd05f
[DOP-4127]: Fix tests
branberry Jan 3, 2024
6ff805f
[DOP-4127]: Fix up localbuild (hopefully)
branberry Jan 4, 2024
c18be50
small clean-up changes
mmeigs Jan 4, 2024
eb872da
clean
mmeigs Jan 4, 2024
2f95a05
dockerfile misspelling
mmeigs Jan 4, 2024
1e8e9a5
[DOP-4127]: Fix up localbuild oas-page-builder
branberry Jan 4, 2024
7002c09
[DOP-4127]: Fix up localbuild
branberry Jan 5, 2024
3e34317
[DOP-4127]: Fix readme error
branberry Jan 5, 2024
6d777ff
preprd
mmeigs Jan 8, 2024
a9c96eb
Update README.md
mmeigs Jan 8, 2024
c679c3f
remove preprd
mmeigs Jan 8, 2024
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
14 changes: 8 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
"version": "0.2.0",
"configurations": [
{
"name": "Docker: Attach to Autobuilder",
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/modules/oas-page-builder/tests/unit/services/pageBuilder.test.ts",
"preLaunchTask": "tsc: build - tsconfig.json",
"outFiles": ["${workspaceFolder}/build/**/*.js"]
"request": "attach",
"port": 9229,
"address": "localhost",
"localRoot": "${workspaceFolder}",
"remoteRoot": "/home/docsworker-xlarge",
"autoAttachChildProcesses": false,
"protocol": "inspector"
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"debug.javascript.autoAttachFilter": "disabled"
}
78 changes: 49 additions & 29 deletions Dockerfile.local
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM arm64v8/ubuntu:20.04
FROM arm64v8/ubuntu:20.04 as initial
ARG NPM_BASE_64_AUTH
ARG NPM_EMAIL
ARG SNOOTY_PARSER_VERSION=0.15.0
Expand All @@ -7,10 +7,13 @@ ARG MUT_VERSION=0.10.7
ARG REDOC_CLI_VERSION=1.2.3
ARG NPM_BASE_64_AUTH
ARG NPM_EMAIL
ARG WORK_DIRECTORY=/home/docsworker-xlarge

ENV DEBIAN_FRONTEND=noninteractive
WORKDIR ${WORK_DIRECTORY}

# helper libraries for docs builds
RUN apt-get update && apt-get install -y vim git unzip zip
RUN apt-get update && apt-get install -y vim git unzip zip chromium-browser rsync

# get node 18
# https://gist.github.com/RinatMullayanov/89687a102e696b1d4cab
Expand All @@ -20,7 +23,6 @@ RUN apt-get install --yes nodejs
RUN apt-get install --yes build-essential
RUN apt-get install --yes python3-pip libxml2-dev libxslt-dev python-dev pkg-config

WORKDIR /app

RUN python3 -m pip install poetry

Expand All @@ -39,53 +41,66 @@ RUN git clone -b v${MUT_VERSION} --depth 1 https://github.com/mongodb/mut.git \
&& make package \
&& mv dist/mut /opt/

RUN curl -L -o redoc.zip https://github.com/mongodb-forks/redoc/archive/refs/tags/v${REDOC_CLI_VERSION}.zip \
&& unzip redoc.zip \
mmeigs marked this conversation as resolved.
Show resolved Hide resolved
&& mv redoc-${REDOC_CLI_VERSION} redoc/

ENV PATH="${PATH}:/opt/snooty:/opt/mut:/app/.local/bin"
ENV PATH="${PATH}:/opt/snooty:/opt/mut:/${WORK_DIRECTORY}/.local/bin"

# setup user and root directory
RUN useradd -ms /bin/bash docsworker
RUN chmod 755 -R /app
RUN chown -Rv docsworker /app
USER docsworker
RUN useradd -ms /bin/bash docsworker-xlarge
RUN chmod 755 -R ${WORK_DIRECTORY}
RUN chown -Rv docsworker-xlarge ${WORK_DIRECTORY}
USER docsworker-xlarge

# install snooty frontend and docs-tools
RUN git clone -b v${SNOOTY_FRONTEND_VERSION} --depth 1 https://github.com/mongodb/snooty.git \
&& cd snooty \
&& npm ci --legacy-peer-deps --omit=dev

RUN curl https://raw.githubusercontent.com/mongodb/docs-worker-pool/meta/makefiles/shared.mk -o shared.mk


RUN git clone -b @dop/redoc-cli@${REDOC_CLI_VERSION} --depth 1 https://github.com/mongodb-forks/redoc.git redoc \
# Install dependencies for Redoc CLI
&& cd redoc/ \
&& npm ci --prefix cli/ --omit=dev

FROM initial as persistence

RUN mkdir -p modules/persistence && chmod 755 modules/persistence
COPY modules/persistence/package*.json ./modules/persistence/
RUN cd ./modules/persistence \
&& npm ci --legacy-peer-deps
# Build persistence module

COPY --chown=docsworker-xlarge modules/persistence/tsconfig*.json ./modules/persistence
COPY --chown=docsworker-xlarge modules/persistence/src ./modules/persistence/src/
COPY --chown=docsworker-xlarge modules/persistence/index.ts ./modules/persistence

RUN cd ./modules/persistence \
&& npm run build:esbuild

FROM initial as oas

RUN mkdir -p modules/oas-page-builder && chmod 755 modules/oas-page-builder
COPY modules/oas-page-builder/package*.json ./modules/oas-page-builder/
RUN cd ./modules/oas-page-builder \
&& npm ci --legacy-peer-deps
# Build modules
# OAS Page Builder
COPY --chown=docsworker-xlarge modules/oas-page-builder/tsconfig*.json ./modules/oas-page-builder
COPY --chown=docsworker-xlarge modules/oas-page-builder/src ./modules/oas-page-builder/src/
COPY --chown=docsworker-xlarge modules/oas-page-builder/index.ts ./modules/oas-page-builder

# Root project build
COPY package*.json ./
RUN npm ci --legacy-peer-deps
# Build persistence module
RUN cd ./modules/oas-page-builder \
&& npm run build:esbuild

COPY --chown=docsworker modules/persistence/tsconfig*.json ./modules/persistence
COPY --chown=docsworker modules/persistence/src ./modules/persistence/src/
COPY --chown=docsworker modules/persistence/index.ts ./modules/persistence
FROM initial as root

RUN cd ./modules/persistence \
&& npm run build
COPY --from=persistence --chown=docsworker-xlarge ${WORK_DIRECTORY}/modules/persistence/dist/ ./modules/persistence
COPY --from=oas --chown=docsworker-xlarge ${WORK_DIRECTORY}/modules/oas-page-builder/dist/ ./modules/oas-page-builder

# Build modules
# OAS Page Builder
COPY --chown=docsworker modules/oas-page-builder/tsconfig*.json ./modules/oas-page-builder
COPY --chown=docsworker modules/oas-page-builder/src ./modules/oas-page-builder/src/
COPY --chown=docsworker modules/oas-page-builder/index.ts ./modules/oas-page-builder
# Root project build
COPY package*.json ./
RUN npm ci --legacy-peer-deps

RUN cd ./modules/oas-page-builder \
&& npm run build

COPY tsconfig*.json ./
COPY config config/
Expand All @@ -94,8 +109,13 @@ COPY src src/

RUN npm run build:esbuild

ENV PERSISTENCE_MODULE_PATH=${WORK_DIRECTORY}/modules/persistence/index.js
ENV OAS_MODULE_PATH=${WORK_DIRECTORY}/modules/oas-page-builder/index.js
ENV REDOC_PATH=${WORK_DIRECTORY}/redoc/cli/index.js

RUN mkdir -p modules/persistence && chmod 755 modules/persistence
RUN mkdir repos && chmod 755 repos

EXPOSE 3000

CMD ["node", "--enable-source-maps", "dist/entrypoints/localApp.js"]
CMD ["node", "--inspect-brk=0.0.0.0", "--enable-source-maps", "dist/entrypoints/onDemandApp.js"]
104 changes: 68 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,49 +21,81 @@ To add a new property:
- Go to `infrastructure/ecs-main/ecs-service.yml` `TaskDefinition` section
- Add the new property to the `ContainerDefinitions`/`Environment` section

## Build and Run Docker Image for local testing
## Debug the Autobuilder for Local Testing

The npm build args are required for the portion of the dockerfile that installs the [snooty-frontend]. `NPM_CONFIG__AUTH`
and `NPM_CONFIG_EMAIL` are environment variables available in our working directory. `NPM_CONFIG_{OPTION}` environment
variables can actually be used instead of the `~/.npmrc` file. The reason we need the build args to be `NPM_BASE_64_AUTH`
and `NPM_EMAIL` is because that's what's expected in the `.npmrc` within [snooty-frontend].
### Setup

```shell
docker build --tag=workerpool --build-arg NPM_BASE_64_AUTH=${NPM_CONFIG__AUTH} --build-arg NPM_EMAIL=${NPM_CONFIG_EMAIL} .
```
To debug the Autobuilder for local testing, you first need to ensure the following has been done:

```shell
docker run \
--env MONGO_ATLAS_USERNAME \
--env MONGO_ATLAS_PASSWORD \
--env AWS_ACCESS_KEY_ID \
--env AWS_SECRET_ACCESS_KEY \
--env GITHUB_BOT_USERNAME \
--env GITHUB_BOT_PASSWORD \
--env DB_NAME \
--env XLARGE \
--env SNOOTY_ENV \
--env FASTLY_TOKEN \
--env FASTLY_DOCHUB_MAP \
--env FASTLY_SERVICE_ID \
workerpool
```
1. Docker is running
2. The `~/.aws/credentials` file contains unexpired credentials for the `default` profile

- `MONGO_ATLAS_USERNAME` and `MONGO_ATLAS_PASSWORD` is username/password of atlas database
- `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` are needed for uploading to S3 via [mut](https://github.com/mongodb/mut)
- `GITHUB_BOT_USERNAME` and `GITHUB_BOT_PASSWORD` are needed so builder can access private repos
- `DB_NAME` allows the indication of a pool database (pool, pool_test)
- `XLARGE` true or false indicates whether this instance will run on an XLARGE server or not
- `SNOOTY_ENV` indicates whether the build environment is stage, prod, or dev
- `FASTLY_TOKEN` is needed for connecting to the Fastly edge dictionary
- `FASTLY_DOCHUB_MAP` is the id of the redirect map that we publish dochub links to
- `FASTLY_SERVICE_ID` is the id of the service used for dochub
For retrieving credentials, head to AWS and under `Docs Platform`, click on `Command line or programmatic access`.
![AWS console](images/aws-console-admin.png)

If you are running a local version of the docker image for testing, we have a separate staging environment setup. Testing in this environment is automated through the "stage" branch. Add the following env variables to the `docker run` command:
Copy the value in option 2, `Manually add a profile to your AWS credentials file (Short-term credentials)`.

![Alt text](images/aws-credentials.png)

From there, paste this value in `~/.aws/credentials`, and replace the randomly generated profile (which looks something like `[123456789_AdministratorAccess]`) with `[default]`.
You should now have the correct credentials to run the debugger.

_**NOTE: credentials expire pretty quickly. Not sure how exactly how long they last for, but in my experience they expire in approximately 30 minutes.**_

You should now be all set to run the debugger command:

`npm run debug`

To view all of the options for the command, you can run:

`npm run debug -- --help`

Here is an example of running the local debugger for `cloud-docs`:

`npm run debug -- -o 10gen -n cloud-docs`

Here is an example of running the local debugger for `docs-monorepo/docs-landing` on branch `groot`:

`npm run debug -- -o 10gen -n docs-monorepo -d cloud-docs -b groot`

By default, the environment that is used for the local Autobuilder is `stg`.

### Debugger Behavior

When the command is run, there are several steps that occur before the Autobuilder begins:

1. Environment variables and other information are pulled from Parameter Store
2. The GitHub repository is queried for data to create the job
3. The container is built
- NOTE: If you have not run the debug command before, the build will take a substantial amount of time (approximately 10-15 minutes).
Subsequent builds will be much shorter, especially if the changes are just code changes. If just a code change is made after the initial build, it should only take a few seconds for the build to complete and the container to run. Changes such as updating the version of the Snooty Parser, or the Redoc CLI will cause the builds to take much longer, but these happen much less frequently. The majority of the build should be on the order of a few seconds.
4. The data from step 2 is then added as a record in the `pool_test.queue`.
5. The container is then run, and waits for the user to connect to it via the VSCode debugger.

Once the container starts successfully, you should see something like the following message:

`Debugger listening on ws://0.0.0.0:9229/....`

To connect, click on the debug tab on the left side of your VSCode editor. Make sure the dropdown to the right of the green play button is set to the `Docker: Attach to Autobuilder` configuration. Press the green play button, and you will attach to the container.

### Troubleshooting

The most frequent cause of build failures will be related to expired AWS credentials, or not having Docker running. Also, if you haven't run `npm ci` in a while, you will need to do so as a new dependency was added to run the command.

Occasionally, errors may occur inexplicably, and the error messages may seem unrelated to any change made. Oftentimes, running the following commands can resolve these sporadic issues:

```sh
docker image prune
docker container prune
```
--env DB_NAME
```

Also, another potential error could be due to the Dockerfile.local not being updated. If you are not seeing changes that are occurring in the Autobuilder in another environment, this may be why. For example, the Dockerfile.local could be using an older version of the Snooty Parser.

![Alt text](images/vsode-debugger.png)

By default, the container will break at the first line of code, which will be in a file called `bind.js`. Press the fast-forward button to continue the execution. You are also able to add other breakpoints to stop the application. Once the application is complete, press `CTRL + C` for the terminal to exit out of the connection to the container.

If you receive `CredentialsProviderError: Could not load credentials from any providers`, make sure that there is no env `AWS_PROFILE` defined as a different profile anywhere (such as in the global `~/.zshrc` file). Otherwise, ensure that `AWS_PROFILE` matches the same profile defined in `~/.aws/credentials`.

## Run Tests

Expand Down
24 changes: 23 additions & 1 deletion api/controllers/v1/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import { markBuildArtifactsForDeletion, validateJsonWebhook } from '../../handlers/github';
import { DocsetsRepository } from '../../../src/repositories/docsetsRepository';
import { ReposBranchesDocsetsDocument } from '../../../modules/persistence/src/services/metadata/repos_branches';
import { PushEvent } from '@octokit/webhooks-types';

async function prepGithubPushPayload(
githubEvent: any,

Check warning on line 12 in api/controllers/v1/github.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
repoBranchesRepository: RepoBranchesRepository,
prefix: string,
repoInfo: ReposBranchesDocsetsDocument
Expand Down Expand Up @@ -60,7 +61,7 @@
};
}

export const TriggerBuild = async (event: any = {}, context: any = {}): Promise<any> => {

Check warning on line 64 in api/controllers/v1/github.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type

Check warning on line 64 in api/controllers/v1/github.ts

View workflow job for this annotation

GitHub Actions / test

'context' is assigned a value but never used

Check warning on line 64 in api/controllers/v1/github.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type

Check warning on line 64 in api/controllers/v1/github.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
const client = new mongodb.MongoClient(c.get('dbUrl'));
await client.connect();
const db = client.db(c.get('dbName'));
Expand All @@ -77,7 +78,28 @@
body: errMsg,
};
}
const body = JSON.parse(event.body);
if (!event.body) {
const err = 'Trigger build does not have a body in event payload';
consoleLogger.error('TriggerBuildError', err);
return {
statusCode: 400,
headers: { 'Content-Type': 'text/plain' },
body: err,
};
}

let body: PushEvent;
try {
body = JSON.parse(event.body) as PushEvent;
} catch (e) {
consoleLogger.error('[TriggerBuild]', `ERROR! Could not parse event.body ${e}`);
console.log(`event: ${event} and event body: ${event.body}`);
return {
statusCode: 502,
headers: { 'Content-Type': 'text/plain' },
body: ' ERROR! Could not parse event.body',
};
}

if (body.deleted) {
return {
Expand Down
2 changes: 1 addition & 1 deletion api/controllers/v1/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import { notifyBuildSummary, snootyBuildComplete } from '../../handlers/jobs';
import { DocsetsRepository } from '../../../src/repositories/docsetsRepository';

export const TriggerLocalBuild = async (event: any = {}, context: any = {}): Promise<any> => {

Check warning on line 16 in api/controllers/v1/jobs.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type

Check warning on line 16 in api/controllers/v1/jobs.ts

View workflow job for this annotation

GitHub Actions / test

'context' is assigned a value but never used

Check warning on line 16 in api/controllers/v1/jobs.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
const client = new mongodb.MongoClient(c.get('dbUrl'));
await client.connect();
const db = client.db(c.get('dbName'));
Expand Down Expand Up @@ -90,7 +90,7 @@
await SubmitArchiveJob(jobId);
break;
default:
consoleLogger.error(jobId, 'Invalid status');
consoleLogger.error(jobId, `Invalid status: ${jobStatus}`);
break;
}
} catch (err) {
Expand Down
12 changes: 7 additions & 5 deletions api/controllers/v2/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ async function prepGithubPushPayload(
githubEvent: PushEvent,
repoBranchesRepository: RepoBranchesRepository,
prefix: string,
repoInfo: ReposBranchesDocsetsDocument
repoInfo: ReposBranchesDocsetsDocument,
directory?: string
): Promise<Omit<EnhancedJob, '_id'>> {
const branch_name = githubEvent.ref.split('/')[2];
const branch_info = await repoBranchesRepository.getRepoBranchAliases(
Expand Down Expand Up @@ -53,6 +54,7 @@ async function prepGithubPushPayload(
urlSlug: urlSlug,
prefix: prefix,
project: project,
directory: directory,
},
logs: [],
};
Expand Down Expand Up @@ -110,7 +112,7 @@ export const TriggerBuild = async (event: APIGatewayEvent): Promise<APIGatewayPr
async function createAndInsertJob(path?: string) {
const repoInfo = await docsetsRepository.getRepo(body.repository.name, path);
const jobPrefix = repoInfo?.prefix ? repoInfo['prefix'][env] : '';
const job = await prepGithubPushPayload(body, repoBranchesRepository, jobPrefix, repoInfo);
const job = await prepGithubPushPayload(body, repoBranchesRepository, jobPrefix, repoInfo, path);

consoleLogger.info(job.title, 'Creating Job');
const jobId = await jobRepository.insertJob(job, c.get('jobsQueueUrl'));
Expand All @@ -128,10 +130,10 @@ export const TriggerBuild = async (event: APIGatewayEvent): Promise<APIGatewayPr
ownerName: body.repository.owner.name,
updatedFilePaths: getUpdatedFilePaths(body.head_commit),
});
consoleLogger.info('monoRepoPaths', `Monorepo Paths with new changes: ${monorepoPaths}`);
consoleLogger.info(body.repository.full_name, `Monorepo Paths with new changes: ${monorepoPaths}`);
}
} catch (error) {
console.warn('Warning, attempting to get repo paths caused an error', error);
consoleLogger.warn('Warning, attempting to get monorepo paths caused an error', error);
}

/* Create and insert Job for each monorepo project that has changes */
Expand All @@ -141,7 +143,7 @@ export const TriggerBuild = async (event: APIGatewayEvent): Promise<APIGatewayPr
if (path.split('/').length > 1) continue;

try {
await createAndInsertJob(`/${path}`);
await createAndInsertJob(path);
} catch (err) {
return {
statusCode: 500,
Expand Down
4 changes: 2 additions & 2 deletions api/controllers/v2/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const HandleJobs = async (event: SQSEvent): Promise<void> => {
await notifyBuildSummary(jobId);
break;
default:
consoleLogger.error(jobId, 'Invalid status');
consoleLogger.error(jobId, `Invalid status: ${jobStatus}`);
mmeigs marked this conversation as resolved.
Show resolved Hide resolved
break;
}
} catch (err) {
Expand Down Expand Up @@ -150,7 +150,7 @@ async function NotifyBuildProgress(jobId: string): Promise<void> {
return;
}

const jobTitle = fullDocument.title;
const jobTitle = `${fullDocument.title}${fullDocument.payload.directory ? `/${fullDocument.payload.directory}` : ''}`;
const username = fullDocument.user;
const repoEntitlementRepository = new RepoEntitlementsRepository(db, c, consoleLogger);
const entitlement = await repoEntitlementRepository.getSlackUserIdByGithubUsername(username);
Expand Down
Loading
Loading