Merge pull request #2235 from balena-os/prettierrc

Supervisor Developer experience improvements
This commit is contained in:
flowzone-app[bot] 2024-01-26 14:50:14 +00:00 committed by GitHub
commit 1346527ec9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 27 additions and 16 deletions

View File

@ -11,5 +11,6 @@ insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
[*.json]
[*.{json,yml}]
indent_style = space
indent_size = 2

5
.prettierrc.js Normal file
View File

@ -0,0 +1,5 @@
const fs = require('fs');
module.exports = JSON.parse(
fs.readFileSync('./node_modules/@balena/lint/config/.prettierrc', 'utf8'),
);

View File

@ -127,6 +127,7 @@ COPY --from=build-base /usr/src/app/node_modules ./node_modules
#dev-cmd-live=LIVEPUSH=1 ./entry.sh
# Copy build files
COPY entry.sh .
COPY build-utils ./build-utils
COPY webpack.config.js tsconfig.json tsconfig.release.json tsconfig.js.json .mochapodrc.yml ./
COPY typings ./typings

View File

@ -39,7 +39,6 @@ Here's a few guidelines to make the process easier for everyone involved.
- Commits should be squashed as much as makes sense.
- Commits should be signed-off (`git commit -s`)
## Developing the supervisor
### Requirements
@ -64,9 +63,9 @@ npm ci
We explicitly use `npm ci` over `npm install` to ensure the correct package versions are installed. More documentation for this can be found [here](https://docs.npmjs.com/cli/ci) on the npm cli docs.
You're now ready to start developing.
You're now ready to start developing.
### Running your code
### Running your code
By far the most convenient way to test your supervisor code is
to download a development image of balenaOS from the
@ -216,12 +215,6 @@ Alternatively, you can launch a test environment using the following commands.
```
# Launch the environment
npm run test:env
# In another terminal, access the sut container
docker-compose exec -i sut sh
# Or alternatively, access the sut container using docker exec
docker exec -ti $(docker ps -q --filter="name=_sut") sh
```
And then run all tests using

View File

@ -1,6 +1,17 @@
version: '2.3'
services:
balena-supervisor-sut:
build:
context: ./
dockerfile: Dockerfile.template
target: test
args:
ARCH: ${ARCH:-amd64}
environment:
LIVEPUSH: '1'
volumes:
- './src:/usr/src/app/src'
sut:
command: sleep infinity
volumes:

View File

@ -39,7 +39,7 @@ services:
MOCK_SYSTEMD_UNITS: openvpn.service avahi.socket
docker:
image: docker:dind
image: docker:24-dind
stop_grace_period: 3s
privileged: true
environment:

View File

@ -17,8 +17,8 @@
"test:integration:single": "find test/integration -name *.spec.ts | xargs mocha --config test/integration/.mocharc.js",
"test:legacy": "mocha --config test/legacy/.mocharc.js",
"test:node": "npm run test:unit && npm run test:integration && npm run test:legacy",
"test:env": "ARCH=$(./build-utils/detect-arch.sh) docker compose -f docker-compose.test.yml -f docker-compose.dev.yml up --build; npm run compose:down",
"test:compose": "ARCH=$(./build-utils/detect-arch.sh) docker compose -f docker-compose.yml -f docker-compose.test.yml up sut --build --remove-orphans --exit-code-from=sut ; npm run compose:down",
"test:env": "ARCH=$(./build-utils/detect-arch.sh) docker compose -f docker-compose.test.yml -f docker-compose.dev.yml run --build --rm sut sh; npm run compose:down",
"test:compose": "(ARCH=$(./build-utils/detect-arch.sh) docker compose -f docker-compose.yml -f docker-compose.test.yml run --build --rm sut || docker compose logs); npm run compose:down",
"test": "npm run lint && npm run test:build && npm run test:unit",
"compose:down": "docker compose -f docker-compose.yml -f docker-compose.test.yml down --volumes",
"prettify": "balena-lint -e ts -e js --fix src/ test/ typings/ build-utils/ webpack.config.js",

View File

@ -21,8 +21,8 @@ describe('lib/docker-utils', () => {
Driver: 'default',
Config: [
{
Gateway: '10.0.105.1',
Subnet: '10.0.105.0/16',
Gateway: '10.105.0.1',
Subnet: '10.105.0.0/16',
},
],
},
@ -36,7 +36,7 @@ describe('lib/docker-utils', () => {
// test using existing data...
it('should return the correct gateway address for supervisor0', async () => {
const gateway = await dockerUtils.getNetworkGateway('supervisor0');
expect(gateway).to.equal('10.0.105.1');
expect(gateway).to.equal('10.105.0.1');
});
it('should return the correct gateway address for host', async () => {