diff --git a/.docker/Dockerfile b/.docker/Dockerfile index c04abec..cce3dfb 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 @@ -20,6 +21,7 @@ COPY . . RUN chmod +x ./scripts/*.sh || true # Set up git RUN apk add git -ADD 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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..dbaaaf3 --- /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: + test: + 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 + outputs: type=docker + + - name: Run tests + env: + DOCKER_BUILDKIT: 0 + run: | + docker run --rm --memory=1g \ + -v ${{ github.workspace }}:/chatbot_server \ + -w /chatbot_server \ + test-chatbot \ + sh -c "pnpm install --frozen-lockfile && pnpm test" \ No newline at end of file