From 2c016eab807366bcde9a5abb2f964c4bc5f281db Mon Sep 17 00:00:00 2001 From: Mark de Dios Date: Tue, 24 Jun 2025 13:03:39 -0700 Subject: [PATCH 1/6] Add github action for tseting a PR branch on push --- .github/workflows/test.yml | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..49490ae --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,43 @@ +name: Test code + +on: + workflow_dispatch: + pull_request: + +permissions: + contents: read + +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + +jobs: + lint: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + + - name: Check out repo + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and run linter + uses: docker/build-push-action@v5 + with: + context: . + file: .docker/Dockerfile + tags: test-chatbot + cache-from: type=gha + cache-to: type=gha,mode=max + outputs: type=docker + + - name: Run linter + run: | + docker run --rm --memory=1g \ + -v ${{ github.workspace }}:/chatbot_server \ + -w /chatbot_server \ + lint-chatbot-server \ + sh -c "pnpm install --frozen-lockfile && pnpm test" \ No newline at end of file From 61c2f7462dd5b10f11792c35c17fe0e0bde4e4a6 Mon Sep 17 00:00:00 2001 From: Mark de Dios Date: Tue, 24 Jun 2025 13:07:21 -0700 Subject: [PATCH 2/6] Add copy scripts/ line to dockerfile --- .docker/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index c04abec..a283ae4 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -6,6 +6,7 @@ RUN corepack use pnpm@* ARG WORKDIR=/chatbot_server WORKDIR ${WORKDIR} +COPY scripts/ ${WORKDIR}/scripts/ # Adding package.json first will cache our dependencies so # that they do not have to be re-installed when the image rebuilds From da71d87af6f0c9c0eb8cadb18f664b8cf086bbf1 Mon Sep 17 00:00:00 2001 From: Mark de Dios Date: Tue, 24 Jun 2025 13:16:24 -0700 Subject: [PATCH 3/6] Replace add with copy for gitconfig --- .docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index a283ae4..16b625c 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -21,6 +21,6 @@ COPY . . RUN chmod +x ./scripts/*.sh || true # Set up git RUN apk add git -ADD git-config.txt ${WORKDIR} +COPY git-config.txt ${WORKDIR} EXPOSE 7000 \ No newline at end of file From 0ae96672ffa06d595e39f1b1b1aa2904aef14d56 Mon Sep 17 00:00:00 2001 From: Mark de Dios Date: Tue, 24 Jun 2025 13:20:49 -0700 Subject: [PATCH 4/6] Sync tax for test-chatbot, remove cache-to, cache-from --- .github/workflows/test.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 49490ae..1e45885 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,8 +30,6 @@ jobs: context: . file: .docker/Dockerfile tags: test-chatbot - cache-from: type=gha - cache-to: type=gha,mode=max outputs: type=docker - name: Run linter @@ -39,5 +37,5 @@ jobs: docker run --rm --memory=1g \ -v ${{ github.workspace }}:/chatbot_server \ -w /chatbot_server \ - lint-chatbot-server \ + test-chatbot \ sh -c "pnpm install --frozen-lockfile && pnpm test" \ No newline at end of file From 6a9ee25fd521e0f6700acaacfcaed43dd0c57715 Mon Sep 17 00:00:00 2001 From: Mark de Dios Date: Tue, 24 Jun 2025 13:24:41 -0700 Subject: [PATCH 5/6] Set docker buildkit to 0 in gitconfig --- .github/workflows/test.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1e45885..dbaaaf3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ concurrency: cancel-in-progress: true jobs: - lint: + test: runs-on: ubuntu-latest timeout-minutes: 5 steps: @@ -32,7 +32,9 @@ jobs: tags: test-chatbot outputs: type=docker - - name: Run linter + - name: Run tests + env: + DOCKER_BUILDKIT: 0 run: | docker run --rm --memory=1g \ -v ${{ github.workspace }}:/chatbot_server \ From 11a40b70cf74f5b0619e1f7731d2cbf64e9d20af Mon Sep 17 00:00:00 2001 From: Mark de Dios Date: Tue, 24 Jun 2025 13:29:14 -0700 Subject: [PATCH 6/6] Add conditional for copying git config if exists, otherwise --- .docker/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 16b625c..cce3dfb 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -21,6 +21,7 @@ COPY . . RUN chmod +x ./scripts/*.sh || true # Set up git RUN apk add git -COPY git-config.txt ${WORKDIR} + +RUN if [ -f git-config.txt ]; then cp git-config.txt ~/.gitconfig; fi EXPOSE 7000 \ No newline at end of file