Skip to content

Commit

Permalink
Merge branch 'main' into ews-add-github-actions-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
sangaline committed Mar 15, 2024
2 parents 0a046d7 + 1bfc70d commit dde2bd7
Show file tree
Hide file tree
Showing 58 changed files with 51,414 additions and 80,887 deletions.
22 changes: 16 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,24 @@ on:

jobs:
lint-and-test:
strategy:
matrix:
version: [18, 19, 20, 21]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.18.2
node-version: ${{ matrix.version }}
cache: yarn

- name: Install JavaScript Dependencies
run: |
yarn install --frozen-lockfile
yarn install --frozen-lockfile --ignore-engines
- name: Lint
if: success() || failure()
Expand All @@ -40,11 +43,18 @@ jobs:
run: |
yarn build
- name: Install Chrome Dependencies
if: success() || failure()
# We only run the browser tests for the development version of node because the browser environment
# is independent of the node version, so all that matters is the build we deploy works in the browser.
- name: Conditionally Install Chrome Dependencies
if: (success() || failure()) && matrix.version == 18
run: |
sudo apt-get install -y libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libgbm1 libasound2 libpangocairo-1.0-0 libxss1 libgtk-3-0
- name: Conditionally Remove Browser Tests
if: (success() || failure()) && matrix.version != 18
run: |
rm test/browser.test.ts
- name: Test
if: success() || failure()
run: |
Expand All @@ -61,7 +71,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.18.2
node-version: 18.19.0
registry-url: "https://registry.npmjs.org"

- name: Extract Version from Tag
Expand Down
3 changes: 2 additions & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
nodejs v18.18.2
nodejs v18.19.0
yarn 1.22.19
12 changes: 9 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18.18.2-slim as development
FROM node:18.19.0-slim as development
ENV NODE_ENV=development

# Optionally convert the user to another UID/GUID to match host user file permissions.
Expand All @@ -15,7 +15,7 @@ RUN if [ "$UID" != "1000" ]; then \
; fi

RUN apt-get update
RUN apt-get install --yes git \
RUN apt-get install --yes git python3 \
`# Chromium installation dependencies` \
curl unzip \
`# Chromium runtime dependencies` \
Expand Down Expand Up @@ -50,10 +50,16 @@ WORKDIR /sindri/
# Link the `sindri-js` project.
# We need at least `package.json` and a stub for the CLI to create the symlinks,
# then we'll bind mount over this with the real project at runtime with docker compose.
# Running `npm link` requires `patch-package` to be in the PATH as a `postinstall` script,
# so we create a small stub script to satisfy this requirement and then delete it.
COPY ./package.json /sindri/package.json
RUN mkdir -p dist/cli/ && \
touch dist/cli/index.js && \
chmod u+x dist/cli/index.js && \
npm link
echo "#! /bin/sh" > patch-package && \
chmod u+x patch-package && \
export PATH="./:$PATH" && \
npm link && \
rm patch-package

CMD ["/bin/sh", "-c", "yarn install && yarn build:watch"]
1 change: 0 additions & 1 deletion ava.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export default {
ts: "module",
},
files: ["test/**/*.test.ts"],
nodeArguments: ["--loader=tsx"],
// Increase the timeout if we expect to make live API calls.
timeout: ["dryrun", "record", "update", "wild"].includes(
process.env.NOCK_BACK_MODE ?? "lockdown",
Expand Down
17 changes: 17 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ services:
GID: "${GID:-1000}"
UID: "${UID:-1000}"
command: ["/bin/sh", "-c", "yarn install && yarn build:watch"]
depends_on:
- socat-docker-bridge
environment:
- DOCKER_HOST=tcp://localhost:2375
- SINDRI_DEVELOPMENT_HOST_ROOT=${PWD}
init: true
network_mode: host
extra_hosts:
Expand All @@ -17,7 +22,19 @@ services:
volumes:
- ./:/sindri/
- ~/.gitconfig:/home/node/.gitconfig
- /tmp/sindri:/tmp/sindri
- /var/run/docker.sock:/var/run/docker.sock
- yarn-cache:/home/node/.cache/yarn/

# Expose the host's `/var/run/docker.sock` socket as TCP port 2375 using socat as the bridge.
# This allows the `sindri-js` container to access the host's docker daemon without root.
socat-docker-bridge:
image: alpine/socat
command: tcp-listen:2375,fork,reuseaddr unix-connect:/var/run/docker.sock
user: root
volumes:
- /var/run/docker.sock:/var/run/docker.sock
network_mode: host

volumes:
yarn-cache:
41 changes: 24 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"templates/",
"tsconfig.json"
],
"engines": {
"node": ">=18.13.0"
},
"main": "dist/lib/index.js",
"module": "dist/lib/index.mjs",
"bin": {
Expand All @@ -49,15 +52,15 @@
"download-sindri-manifest-schema": "nwget https://sindri.app/api/v1/sindri-manifest-schema.json -O sindri-manifest.json && prettier --write sindri-manifest.json",
"download-sindri-manifest-schema:dev": "nwget http://localhost/api/v1/sindri-manifest-schema.json -O sindri-manifest.json && prettier --write sindri-manifest.json",
"download-sindri-manifest-schema:docker": "nwget http://host.docker.internal/api/v1/sindri-manifest-schema.json -O sindri-manifest.json && prettier --write sindri-manifest.json",
"generate-api": "rm -rf src/lib/api/ && openapi --client axios --input https://sindri.app/api/openapi.json --output src/lib/api/ && prettier --write src/lib/api/**/*",
"generate-api:dev": "rm -rf src/lib/api/ && openapi --client axios --input http://localhost/api/openapi.json --output src/lib/api/ && prettier --write src/lib/api/**/*",
"generate-api:docker": "rm -rf src/lib/api/ && openapi --client axios --input http://host.docker.internal/api/openapi.json --output src/lib/api/ && prettier --write src/lib/api/**/*",
"generate-api": "mv src/lib/api/core/request.ts tmp-request.ts && rm -rf src/lib/api/ && openapi --client axios --input https://sindri.app/api/openapi.json --name ApiClient --output src/lib/api/ --request tmp-request.ts --useUnionTypes && rm tmp-request.ts && prettier --write src/lib/api/**/*",
"generate-api:dev": "mv src/lib/api/core/request.ts tmp-request.ts && rm -rf src/lib/api/ && openapi --client axios --input http://localhost/api/openapi.json --name ApiClient --output src/lib/api/ --request tmp-request.ts --useUnionTypes && rm tmp-request.ts && prettier --write src/lib/api/**/*",
"generate-api:docker": "mv src/lib/api/core/request.ts tmp-request.ts && rm -rf src/lib/api/ && openapi --client axios --input http://host.docker.internal/api/openapi.json --name ApiClient --output src/lib/api/ --request tmp-request.ts --useUnionTypes && rm tmp-request.ts && prettier --write src/lib/api/**/*",
"lint": "eslint '**/*.{js,ts}'",
"format": "prettier --write '**/*.{js,json,md,ts}'",
"test": "yarn build && ava",
"test:fast": "ava",
"test": "yarn build && yarn test:fast",
"test:fast": "tsx ./node_modules/.bin/ava",
"test:record": "NOCK_BACK_MODE=update yarn test",
"test:watch": "NODE_ENV=development NOCK_BACK_MODE=dryrun nodemon --watch src/ --watch test/ --ext js,cjs,mjs,ts,cts,mts --exec 'tsup --silent && ava'",
"test:watch": "NODE_ENV=development NOCK_BACK_MODE=dryrun nodemon --watch src/ --watch test/ --ext js,cjs,mjs,ts,cts,mts --exec 'tsup --silent && tsx ./node_modules/.bin/ava'",
"type-check": "tsc --noEmit",
"/***** Hooks *****/": "",
"postinstall": "patch-package"
Expand All @@ -74,8 +77,19 @@
"dependencies": {
"@commander-js/extra-typings": "^11.1.0",
"@inquirer/prompts": "^3.3.0",
"@tsconfig/node18": "^18.2.2",
"@types/gzip-js": "^0.3.5",
"@types/ignore-walk": "^4.0.3",
"@types/lodash": "^4.14.202",
"@types/node": "^20.9.1",
"@types/nunjucks": "^3.2.6",
"@types/proxy": "^1.0.4",
"@types/tar": "^6.1.10",
"@types/tar-js": "^0.3.5",
"axios": "^1.6.2",
"commander": "^11.1.0",
"compare-versions": "^6.1.0",
"dockerode": "^4.0.2",
"env-paths": "^2.2.1",
"formdata-node": "^6.0.3",
"gzip-js": "^0.3.2",
Expand All @@ -90,27 +104,20 @@
"rc": "^1.2.8",
"tar": "^6.2.0",
"tar-js": "^0.3.0",
"@tsconfig/node18": "^18.2.2",
"@types/get-port": "^4.2.0",
"@types/gzip-js": "^0.3.5",
"@types/ignore-walk": "^4.0.3",
"@types/lodash": "^4.14.202",
"@types/node": "^20.9.1",
"@types/nunjucks": "^3.2.6",
"@types/proxy": "^1.0.4",
"@types/tar": "^6.1.10",
"@types/tar-js": "^0.3.5",
"zod": "^3.22.4"
},
"devDependencies": {
"@ava/typescript": "^4.1.0",
"@types/dockerode": "^3.3.23",
"@types/sarif": "^2.1.7",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.11.0",
"ava": "^6.0.1",
"esbuild": "^0.19.11",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"flatted": "^3.3.1",
"get-port": "^7.0.0",
"http-mitm-proxy": "^1.1.0",
"make-synchronous": "^1.0.0",
Expand All @@ -120,7 +127,7 @@
"openapi-typescript-codegen": "^0.25.0",
"parse-multipart-data": "^1.5.0",
"prettier": "^3.1.0",
"puppeteer": "^21.7.0",
"puppeteer": "^22.2.0",
"rollup": "^4.9.5",
"tsup": "^7.3.0",
"tsx": "^4.7.0",
Expand Down
Loading

0 comments on commit dde2bd7

Please sign in to comment.