Skip to content

Commit

Permalink
Merge pull request #536 from microbit-foundation/main
Browse files Browse the repository at this point in the history
V3.2
  • Loading branch information
Karlo-Emilo authored Oct 10, 2024
2 parents 08471ad + ab6fda7 commit 83b89ea
Show file tree
Hide file tree
Showing 250 changed files with 38,891 additions and 43,473 deletions.
26 changes: 12 additions & 14 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
* SPDX-License-Identifier: MIT
*/
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:svelte/recommended',
],
parserOptions: {
ecmaVersion: 2020,
Expand All @@ -18,28 +20,24 @@ module.exports = {
extraFileExtensions: ['.svelte'],
},
env: {
es6: true,
browser: true,
es6: true,
node: true,
},
overrides: [
{
files: ['*.svelte'],
processor: 'svelte3/svelte3',
parser: 'svelte-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
},
},
],
settings: {
'svelte3/typescript': require('typescript'),
// ignore style tags in Svelte because of Tailwind CSS
// See https://github.com/sveltejs/eslint-plugin-svelte3/issues/70
'svelte3/ignore-styles': () => true,
},
globals: {
NodeJS: true,
process: true,
},
plugins: ['svelte3', '@typescript-eslint'],
ignorePatterns: ['node_modules', 'svelte.config.js', '.eslintrc.cjs'],
plugins: ['@typescript-eslint'],
ignorePatterns: [
'node_modules',
'svelte.config.js',
'.eslintrc.cjs',
'babel.config.cjs',
],
};
26 changes: 18 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,29 @@ permissions:
contents: read

jobs:
Jest:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run Tests
run: |
npm install
npm ci
npm test
formatting_and_linting:
name: Prettier / svelte Check
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Run prettier
shell: bash
run: |
npm ci
npm run checkFormat
- name: Svelte check
shell: bash
run: npm run check

build_and_deploy:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
Expand All @@ -43,9 +58,6 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- name: Branding
run: |
cp -f ./src/__viteBuildVariants__/ml-machine/windi.config.js ./windi.config.js
- name: Build And Deploy
uses: Azure/static-web-apps-deploy@1a947af9992250f3bc2e68ad0754c0b0c11566c9
with:
Expand All @@ -54,8 +66,6 @@ jobs:
action: "upload"
app_location: ${{ env.APP_LOCATION }}
app_artifact_location: ${{ env.APP_ARTIFACT_LOCATION }}
env:
VITE_TITLE: ML-Machine

close:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
Expand All @@ -66,4 +76,4 @@ jobs:
uses: Azure/static-web-apps-deploy@1a947af9992250f3bc2e68ad0754c0b0c11566c9
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
action: "close"
action: "close"
9 changes: 2 additions & 7 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ permissions:
contents: read

jobs:
Jest:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run Tests
run: |
npm install
npm ci
npm test
build_and_deploy:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
Expand All @@ -43,9 +43,6 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- name: Branding
run: |
cp -f ./src/__viteBuildVariants__/ml-machine/windi.config.js ./windi.config.js
- name: Build And Deploy
uses: Azure/static-web-apps-deploy@1a947af9992250f3bc2e68ad0754c0b0c11566c9
with:
Expand All @@ -54,8 +51,6 @@ jobs:
action: "upload"
app_location: ${{ env.APP_LOCATION }}
app_artifact_location: ${{ env.APP_ARTIFACT_LOCATION }}
env:
VITE_TITLE: ML-Machine

close:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
Expand Down
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
src/translations.ts
src/translations.ts
src/appInsights.ts
src/messages/*
17 changes: 14 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@
"a11y-distracting-elements": "ignore",
"a11y-structure": "ignore",
"a11y-click-events-have-key-events": "ignore",
"a11y-missing-content": "ignore"
}
}
"a11y-missing-content": "ignore",
"a11y-no-noninteractive-element-interactions": "ignore",
"a11y-no-static-element-interactions": "ignore"
},
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true
},
"hide-files.files": []
}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Please note we have a code of conduct, please follow it in all your interactions

## Pull Request Process

1. Ensure any install or build dependencies are removed and the tests using `jest` are running successfully.
1. Ensure any install or build dependencies are removed and the tests using `npm run test` are running successfully.
2. Update the README.md with details of changes to the interface, this includes new environment
variables and useful file locations, if applicable.
3. Increase the version numbers in any examples files and the README.md to the new version that this
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ We recommend starting here.

### ```npm test```

Runs the test suite. Tests are driven by the framework [Jest](https://jestjs.io/). Runs all tests inside the folder `./src/__tests__/`.
Runs the test suite. Tests are driven by the framework [Vitest](https://vitest.dev/). Runs all tests inside the folder `./src/__tests__/`.

If you do not plan to contribute to the project, you may safely ignore this.

Expand Down
5 changes: 5 additions & 0 deletions babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [
['@babel/preset-env', {targets: {node: 'current'}}],
],
};
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
ml:
build: .
ports:
- "5174:8080"
25 changes: 25 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# A Dockerfile must begin with a FROM instruction.
# New base image will be built based on the Node.js version 20
# Image that is based on Debian Linux.
FROM node:20

# Create app directory
WORKDIR /usr/src/app

# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json ./

# Install app dependencies
RUN npm install
RUN npm install express

# Bundle app source
COPY . .

# Creates a "dist" folder with the production build
RUN npm run build

EXPOSE 8080

# Start the server using the production build
CMD [ "node", "dist/main.cjs" ]
6 changes: 6 additions & 0 deletions features.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"title": "Learning tool",
"knnModel": true,
"lossGraph": true,
"makecode": true
}
14 changes: 10 additions & 4 deletions microbit/v1/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ void sendString(ManagedString s)
void onConnected(MicroBitEvent)
{
connected = 1; // Set the connected flag
uBit.sleep(3000);
uart->send(ManagedString("id_prop")); // MUST be sent before vi_ message
uart->send(ManagedString("vi_") + ManagedString(buildNumber));

const uint8_t smiley[] {
0, 0, 0, 0, 0,
0, 1, 0, 1, 0,
Expand All @@ -59,6 +55,16 @@ void onConnected(MicroBitEvent)

MicroBitImage happy(5,5,smiley);
uBit.display.print(happy);

for (size_t i = 0; i < 12; i++)
{
if (!connected) {
break;
}
uBit.sleep(1000);
uart->send(ManagedString("id_prop")); // MUST be sent before vi_ message
uart->send(ManagedString("vi_") + ManagedString(buildNumber));
}
}

/**
Expand Down
14 changes: 10 additions & 4 deletions microbit/v2/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,17 @@ void onConnected(MicroBitEvent)
{
connected = 1; // Set the connected flag

uBit.sleep(3000);
uart->send(ManagedString("id_prop")); // MUST be sent before vi_ message
uart->send(ManagedString("vi_") + ManagedString(buildNumber));

printSmiley(GLAD_SMILEY);

for (size_t i = 0; i < 12; i++)
{
if (!connected) {
break;
}
uBit.sleep(1000);
uart->send(ManagedString("id_prop")); // MUST be sent before vi_ message
uart->send(ManagedString("vi_") + ManagedString(buildNumber));
}
}

/**
Expand Down
Loading

0 comments on commit 83b89ea

Please sign in to comment.