-
Notifications
You must be signed in to change notification settings - Fork 4
641: wip #665
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
Open
tahminator
wants to merge
10
commits into
main
Choose a base branch
from
641
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
641: wip #665
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
48a9aa1
641: wip
tahminator ae86667
641: wip pt2
tahminator fde3821
641: wip pt3
tahminator b0bc9b9
641: blee bloo bleeeeeeee
tahminator 5cbc96c
641: blee bloo bleeeeeeee wefklfkenfwekjnfg
tahminator c2fe246
641: blee
tahminator 8882bfb
641: lsdfnsdgvlndefblnerb
tahminator b8d4c40
641: neenurrr
tahminator 8d61d5c
641: attempt
tahminator 1091b04
641: try to fix messed up leetcodeclienttest
tahminator File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| name: "Build & Upload Docker Image" | ||
| description: "Build & (optionally) upload Docker Image to Docker Registry" | ||
|
|
||
| inputs: | ||
| GPG_PRIVATE_KEY: | ||
| description: "GPG Private Key" | ||
| required: true | ||
| GPG_PASSPHRASE: | ||
| description: "GPG Passphrase" | ||
| required: true | ||
| DOCKER_UPLOAD: | ||
| description: "Boolean indicating whether the image should be uploaded to Docker registry or not." | ||
| required: false | ||
| default: true | ||
| TAG_PREFIX: | ||
| description: "Docker tags prefix" | ||
| required: false | ||
| SERVER_PROFILES: | ||
| description: "Profile(s) to apply to Codebloom instance." | ||
| required: false | ||
| default: prod | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Disable man-db | ||
| uses: ./.github/composite/disable-mandb | ||
|
|
||
| - name: Set up pnpm | ||
| uses: pnpm/action-setup@master | ||
| with: | ||
| version: 10.24.0 | ||
| cache: true | ||
| cache_dependency_path: js/pnpm-lock.yaml | ||
| package_json_file: js/package.json | ||
|
|
||
| - name: Set up OpenJDK 25 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: "temurin" | ||
| java-version: "25" | ||
| cache: "maven" | ||
|
|
||
| - name: Set up bun | ||
| uses: oven-sh/setup-bun@v2 | ||
| with: | ||
| bun-version: latest | ||
|
|
||
| - name: Cache Bun dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.bun/install/cache | ||
| key: ${{ runner.os }}-bun-${{ hashFiles('.github/scripts/bun.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-bun- | ||
|
|
||
| - name: Install deps | ||
| shell: bash | ||
| run: bun install --cwd .github/scripts --frozen-lockfile | ||
|
|
||
| - name: Load secrets | ||
| uses: ./.github/composite/load-secrets | ||
| with: | ||
| GPG_PRIVATE_KEY: ${{ inputs.GPG_PRIVATE_KEY }} | ||
| GPG_PASSPHRASE: ${{ inputs.GPG_PASSPHRASE }} | ||
| UNLOAD_ENVIRONMENTS: ci,ci-app | ||
|
|
||
| - name: Expose GitHub Runtime | ||
| uses: crazy-max/ghaction-github-runtime@v3 | ||
|
|
||
| - name: Run script | ||
| shell: bash | ||
| run: bun .github/scripts/build-image.ts | ||
| env: | ||
| DOCKER_UPLOAD: ${{ inputs.DOCKER_UPLOAD }} | ||
| TAG_PREFIX: ${{ inputs.TAG_PREFIX }} | ||
| SERVER_PROFILES: ${{ inputs.SERVER_PROFILES }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| name: "Backend test" | ||
| description: "Run backend tests" | ||
|
|
||
| inputs: | ||
| GPG_PRIVATE_KEY: | ||
| description: "GPG Private Key" | ||
| required: true | ||
| GPG_PASSPHRASE: | ||
| description: "GPG Passphrase" | ||
| required: true | ||
| UPLOAD_TEST_COV: | ||
| description: "Boolean indicating whether tests should be uploaded to Codecov or not." | ||
| required: false | ||
| default: true | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Disable man-db | ||
| uses: ./.github/composite/disable-mandb | ||
|
|
||
| - name: Set up OpenJDK 25 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: "temurin" | ||
| java-version: "25" | ||
| cache: "maven" | ||
|
|
||
| - name: Set up bun | ||
| uses: oven-sh/setup-bun@v2 | ||
| with: | ||
| bun-version: latest | ||
|
|
||
| - name: Cache Bun dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.bun/install/cache | ||
| key: ${{ runner.os }}-bun-${{ hashFiles('.github/scripts/bun.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-bun- | ||
|
|
||
| - name: Install deps | ||
| shell: bash | ||
| run: bun install --cwd .github/scripts --frozen-lockfile | ||
|
|
||
| - name: Load secrets | ||
| uses: ./.github/composite/load-secrets | ||
| with: | ||
| GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | ||
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
| UNLOAD_ENVIRONMENTS: ci-app | ||
|
|
||
| - name: Run script | ||
| shell: bash | ||
| run: bun .github/scripts/run-backend-tests.ts | ||
|
|
||
| - name: Upload JaCoCo HTML report | ||
| uses: actions/upload-artifact@v4 | ||
| if: ${{ inputs.UPLOAD_TEST_COV == true }} | ||
| with: | ||
| name: jacoco-report | ||
| path: target/site/jacoco/ | ||
|
|
||
| - name: Upload coverage reports to Codecov | ||
| uses: codecov/codecov-action@v5 | ||
| if: ${{ inputs.UPLOAD_TEST_COV == true }} | ||
| with: | ||
| token: ${{ secrets.CODECOV_TOKEN }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| name: "Frontend Test" | ||
| description: "Run frontend tests" | ||
|
|
||
| inputs: | ||
| GPG_PRIVATE_KEY: | ||
| description: "GPG Private Key" | ||
| required: true | ||
| GPG_PASSPHRASE: | ||
| description: "GPG Passphrase" | ||
| required: true | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Disable man-db | ||
| uses: ./.github/composite/disable-mandb | ||
|
|
||
| - name: Set up pnpm | ||
| uses: pnpm/action-setup@master | ||
| with: | ||
| version: 10.24.0 | ||
| cache: true | ||
| cache_dependency_path: js/pnpm-lock.yaml | ||
| package_json_file: js/package.json | ||
|
|
||
| - name: Set up OpenJDK 25 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: "temurin" | ||
| java-version: "25" | ||
| cache: "maven" | ||
|
|
||
| - name: Set up bun | ||
| uses: oven-sh/setup-bun@v2 | ||
| with: | ||
| bun-version: latest | ||
|
|
||
| - name: Cache Bun dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.bun/install/cache | ||
| key: ${{ runner.os }}-bun-${{ hashFiles('.github/scripts/bun.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-bun- | ||
|
|
||
| - name: Install deps | ||
| shell: bash | ||
| run: bun install --cwd .github/scripts --frozen-lockfile | ||
|
|
||
| - name: Load secrets | ||
| uses: ./.github/composite/load-secrets | ||
| with: | ||
| GPG_PRIVATE_KEY: ${{ inputs.GPG_PRIVATE_KEY }} | ||
| GPG_PASSPHRASE: ${{ inputs.GPG_PASSPHRASE }} | ||
| UNLOAD_ENVIRONMENTS: ci-app | ||
|
|
||
| - name: Run script | ||
| shell: bash | ||
| run: bun .github/scripts/run-frontend-tests.ts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| import { $ } from "bun"; | ||
| import { db } from "./fn/run-local-db"; | ||
| import { backend } from "./fn/run-backend-instance"; | ||
|
|
||
| process.env.TZ = "America/New_York"; | ||
|
|
||
| const tagPrefix = process.env.TAG_PREFIX || ""; | ||
| const shouldDockerUpload = Boolean(process.env.DOCKER_UPLOAD) || false; | ||
| const serverProfiles = process.env.SERVER_PROFILES || "prod"; | ||
|
|
||
| const dockerHubPat = process.env.DOCKER_HUB_PAT; | ||
| if (!dockerHubPat) { | ||
| throw new Error("DOCKER_HUB_PAT is required."); | ||
| } | ||
|
|
||
| async function main() { | ||
| try { | ||
| await db.start(); | ||
| await backend.start(); | ||
|
|
||
| await $`corepack enable pnpm`; | ||
| await $`pnpm --dir js i -D --frozen-lockfile`; | ||
| await $`pnpm --dir js run generate`; | ||
|
|
||
| // copy old tz format from build-image.sh | ||
| const timestamp = new Date() | ||
| .toLocaleString("en-US", { | ||
| timeZone: process.env.TZ, | ||
| year: "numeric", | ||
| month: "2-digit", | ||
| day: "2-digit", | ||
| hour: "2-digit", | ||
| minute: "2-digit", | ||
| second: "2-digit", | ||
| hour12: false, | ||
| }) | ||
| .replace(/(\d+)\/(\d+)\/(\d+),\s(\d+):(\d+):(\d+)/, "$3.$1.$2-$4.$5.$6"); | ||
|
|
||
| const gitSha = (await $`git rev-parse --short HEAD`.text()).trim(); | ||
|
|
||
| const tags = [ | ||
| `tahminator/codebloom:${tagPrefix}latest`, | ||
| `tahminator/codebloom:${tagPrefix}${timestamp}`, | ||
| `tahminator/codebloom:${tagPrefix}${gitSha}`, | ||
| ]; | ||
|
|
||
| console.log("Building image with following tags:"); | ||
| tags.forEach((tag) => console.log(tag)); | ||
|
|
||
| if (dockerHubPat) { | ||
| console.log("DOCKER_HUB_PAT found"); | ||
| } else { | ||
| console.log("DOCKER_HUB_PAT missing or empty"); | ||
| } | ||
|
|
||
| await $`echo ${dockerHubPat} | docker login -u tahminator --password-stdin`; | ||
|
|
||
| try { | ||
| await $`docker buildx create --use --name codebloom-builder`; | ||
| } catch { | ||
| await $`docker buildx use codebloom-builder`; | ||
| } | ||
|
|
||
| const buildMode = shouldDockerUpload ? "--push" : "--load"; | ||
|
|
||
| const viteStagingArg = | ||
| serverProfiles === "stg" ? ["--build-arg", "VITE_STAGING=true"] : []; | ||
|
|
||
| const tagArgs = tags.flatMap((tag) => ["--tag", tag]); | ||
|
|
||
| await $`docker buildx build ${buildMode} \ | ||
| --file infra/Dockerfile \ | ||
| --build-arg SERVER_PROFILES=${serverProfiles} \ | ||
| --build-arg COMMIT_SHA=${gitSha} \ | ||
| --cache-from=type=gha \ | ||
| --cache-to=type=gha,mode=max \ | ||
| ${viteStagingArg} \ | ||
| ${tagArgs} \ | ||
| .`.quiet(); | ||
|
|
||
| console.log("Image pushed successfully."); | ||
| } finally { | ||
| await backend.end(); | ||
| await db.end(); | ||
| } | ||
| } | ||
|
|
||
| main() | ||
| .then(() => { | ||
| process.exit(0); | ||
| }) | ||
| .catch((e) => { | ||
| console.error(e); | ||
| process.exit(1); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.