Skip to content

Commit 1346527

Browse files
Merge pull request #2235 from balena-os/prettierrc
Supervisor Developer experience improvements
2 parents d32987a + 0500fe1 commit 1346527

8 files changed

+27
-16
lines changed

.editorconfig

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ insert_final_newline = true
1111
[*.md]
1212
trim_trailing_whitespace = false
1313

14-
[*.json]
14+
[*.{json,yml}]
1515
indent_style = space
16+
indent_size = 2

.prettierrc.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const fs = require('fs');
2+
3+
module.exports = JSON.parse(
4+
fs.readFileSync('./node_modules/@balena/lint/config/.prettierrc', 'utf8'),
5+
);

Dockerfile.template

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ COPY --from=build-base /usr/src/app/node_modules ./node_modules
127127
#dev-cmd-live=LIVEPUSH=1 ./entry.sh
128128

129129
# Copy build files
130+
COPY entry.sh .
130131
COPY build-utils ./build-utils
131132
COPY webpack.config.js tsconfig.json tsconfig.release.json tsconfig.js.json .mochapodrc.yml ./
132133
COPY typings ./typings

README.md

+2-9
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ Here's a few guidelines to make the process easier for everyone involved.
3939
- Commits should be squashed as much as makes sense.
4040
- Commits should be signed-off (`git commit -s`)
4141

42-
4342
## Developing the supervisor
4443

4544
### Requirements
@@ -64,9 +63,9 @@ npm ci
6463

6564
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.
6665

67-
You're now ready to start developing.
66+
You're now ready to start developing.
6867

69-
### Running your code
68+
### Running your code
7069

7170
By far the most convenient way to test your supervisor code is
7271
to download a development image of balenaOS from the
@@ -216,12 +215,6 @@ Alternatively, you can launch a test environment using the following commands.
216215
```
217216
# Launch the environment
218217
npm run test:env
219-
220-
# In another terminal, access the sut container
221-
docker-compose exec -i sut sh
222-
223-
# Or alternatively, access the sut container using docker exec
224-
docker exec -ti $(docker ps -q --filter="name=_sut") sh
225218
```
226219

227220
And then run all tests using

docker-compose.dev.yml

+11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
version: '2.3'
22

33
services:
4+
balena-supervisor-sut:
5+
build:
6+
context: ./
7+
dockerfile: Dockerfile.template
8+
target: test
9+
args:
10+
ARCH: ${ARCH:-amd64}
11+
environment:
12+
LIVEPUSH: '1'
13+
volumes:
14+
- './src:/usr/src/app/src'
415
sut:
516
command: sleep infinity
617
volumes:

docker-compose.test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ services:
3939
MOCK_SYSTEMD_UNITS: openvpn.service avahi.socket
4040

4141
docker:
42-
image: docker:dind
42+
image: docker:24-dind
4343
stop_grace_period: 3s
4444
privileged: true
4545
environment:

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"test:integration:single": "find test/integration -name *.spec.ts | xargs mocha --config test/integration/.mocharc.js",
1818
"test:legacy": "mocha --config test/legacy/.mocharc.js",
1919
"test:node": "npm run test:unit && npm run test:integration && npm run test:legacy",
20-
"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",
21-
"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",
20+
"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",
21+
"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",
2222
"test": "npm run lint && npm run test:build && npm run test:unit",
2323
"compose:down": "docker compose -f docker-compose.yml -f docker-compose.test.yml down --volumes",
2424
"prettify": "balena-lint -e ts -e js --fix src/ test/ typings/ build-utils/ webpack.config.js",

test/integration/lib/docker-utils.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ describe('lib/docker-utils', () => {
2121
Driver: 'default',
2222
Config: [
2323
{
24-
Gateway: '10.0.105.1',
25-
Subnet: '10.0.105.0/16',
24+
Gateway: '10.105.0.1',
25+
Subnet: '10.105.0.0/16',
2626
},
2727
],
2828
},
@@ -36,7 +36,7 @@ describe('lib/docker-utils', () => {
3636
// test using existing data...
3737
it('should return the correct gateway address for supervisor0', async () => {
3838
const gateway = await dockerUtils.getNetworkGateway('supervisor0');
39-
expect(gateway).to.equal('10.0.105.1');
39+
expect(gateway).to.equal('10.105.0.1');
4040
});
4141

4242
it('should return the correct gateway address for host', async () => {

0 commit comments

Comments
 (0)