Skip to content

Commit

Permalink
chore: type checks as part of the build (#12)
Browse files Browse the repository at this point in the history
* chore: type checks as part of the build

* chore: cleanup

* chore: cleanup
  • Loading branch information
webbertakken authored Apr 19, 2024
1 parent 1b6ef99 commit 95fd7a2
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 31 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,5 @@ jobs:
- name: Formatting
run: yarn prettier --check .

# - name: Typecheck
# run: yarn typecheck

- name: Build
run: yarn build
3 changes: 0 additions & 3 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,5 @@ jobs:
- name: Formatting
run: yarn prettier --check .

# - name: Typecheck
# run: yarn typecheck

- name: Build
run: yarn build
30 changes: 22 additions & 8 deletions tools/docker/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@ ARG BUN_VERSION="1"
# see all versions at https://hub.docker.com/r/bitnami/node/tags
ARG NODE_VERSION="20"

# Build time secrets
ARG HASS_TOKEN
ARG HASS_BASE_URL

###########################################################
## ##
## BUILDER ##
## ##
###########################################################

#FROM bitnami/node:${NODE_VERSION} as builder
#FROM imbios/bun-node:latest-20-debian as builder

FROM bitnami/node:${NODE_VERSION} as builder

# Allow build time secrets in this image
ARG HASS_TOKEN
ARG HASS_BASE_URL

# Act as CI system: no interactive tty, no stdin/stdout, no watch processes
ENV CI="true"

Expand All @@ -38,17 +43,26 @@ COPY src/ /app/src/

# Build and pre-flight checks
RUN cd /app/ \
&& echo "node version: $(node --version)" \
&& echo "yarn version: $(yarn --version)" \
&& echo -e "/app/ folder:\n$(ls -alh)" \
&& yarn install --immutable \
&& yarn test \
&& yarn prettier --check . \
&& yarn lint \
# Note: Can not do typecheck unless we pass in credentials during build time
# && yarn types \
# && yarn typecheck \
&& if [ -n "$HASS_TOKEN" ] && [ -n "$HASS_BASE_URL" ]; then \
echo "HASS_TOKEN provided, running yarn typecheck"; \
yarn type-writer; \
yarn typecheck; \
else \
echo "HASS_TOKEN not provided, skipping yarn typecheck"; \
fi \
&& yarn build:dist \
&& du -sh node_modules \
&& echo -e "dist files:\n$(ls -alh dist | tail -n +4)" \
&& echo "dist size: $(du -sh dist)" \
&& echo "node_modules size including dev dependencies: $(du -sh node_modules)" \
&& yarn workspaces focus --production \
&& du -sh node_modules
&& echo "node modules size after production focus: $(du -sh node_modules)"

###########################################################
## ##
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
"type": "module",
"scripts": {
"dev": "bun --hot --watch src/main.ts",
"sync": "bun tools/scripts/upgrade-da-packages-and-write-types.ts",
"build": "docker build . -f tools/docker/Dockerfile -t automation-prod",
"sync": "yarn up \"@digital-alchemy/*\" && bunx --env-file .env type-writer",
"build": "bun --env-file .env build:docker",
"build:dist": "bun build src/main.ts --target=bun --outfile=dist/server.js",
"build:docker": "docker build . --build-arg HASS_TOKEN=$HASS_TOKEN --build-arg HASS_BASE_URL=$HASS_BASE_URL -t automation-prod",
"start": "docker run --env-file .env automation-prod",
"test": "vitest",
"coverage": "vitest --coverage",
Expand Down
11 changes: 0 additions & 11 deletions tools/scripts/run.ts

This file was deleted.

4 changes: 0 additions & 4 deletions tools/scripts/upgrade-da-packages-and-write-types.ts

This file was deleted.

0 comments on commit 95fd7a2

Please sign in to comment.