Skip to content

Commit

Permalink
Merge pull request #19 from crt25/feature/CRT-24_load_submit_tasks
Browse files Browse the repository at this point in the history
[CRT-24] [CRT-17] Enable solution submissions (+ preparation for scratch tasks)
  • Loading branch information
pierluca authored Oct 28, 2024
2 parents c3f8f8f + b1afd74 commit 1821fb4
Show file tree
Hide file tree
Showing 112 changed files with 7,605 additions and 1,573 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.hex filter=lfs diff=lfs merge=lfs -text
15 changes: 10 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ jobs:
uses: actions/checkout@v4
with:
submodules: 'true'
lfs: 'true'
fetch-depth: 0

- uses: actions/setup-node@v4
with:
node-version: 22

- name: Install backend dependencies
working-directory: ./backend
run: yarn install
Expand All @@ -52,6 +57,10 @@ jobs:
working-directory: ./apps/scratch
run: yarn install

- name: Install playwright dependencies
working-directory: ./apps/scratch
run: yarn playwright install --with-deps

- name: Lint backend
working-directory: ./backend
run: yarn lint
Expand Down Expand Up @@ -87,22 +96,18 @@ jobs:
- name: Test backend
working-directory: ./backend
run: yarn test:cov
continue-on-error: true

- name: End-to-end Test backend
working-directory: ./backend
run: yarn test:e2e:cov
continue-on-error: true

- name: Test frontend
working-directory: ./frontend
run: yarn test:cov
continue-on-error: true

- name: Test scratch app
working-directory: ./apps/scratch
run: yarn test:cov
continue-on-error: true
run: yarn test

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ pids
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# playwright output
test-results

# coverage output from nyc
.nyc_output

# Coverage files used by tools like istanbul
*.lcov

Expand Down
2 changes: 1 addition & 1 deletion apps/scratch/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"extends": ["../../.eslintrc.js", "eslint:recommended", "plugin:prettier/recommended"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"root": true,
Expand Down
3 changes: 3 additions & 0 deletions apps/scratch/assets/scratch-microbit-1.2.0.hex
Git LFS file not shown
16 changes: 14 additions & 2 deletions apps/scratch/craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
/* craco.config.js */
const path = require(`path`);
const webpack = require(`webpack`);
const { getLoader, getLoaders, loaderByName } = require("@craco/craco");
const { getLoaders, loaderByName } = require("@craco/craco");

require("react-scripts/config/env");

// craco plugins
const cracoBabelLoader = require("craco-babel-loader");
Expand Down Expand Up @@ -64,7 +66,7 @@ module.exports = {
remove: [],
},
// https://craco.js.org/docs/configuration/getting-started/#object-literals-and-functions
configure: (webpackConfig) => {
configure: (webpackConfig, { env }) => {
// supress invalid source map warnings - some dependencies have invalid or inexistent source maps
// https://stackoverflow.com/a/70975849/2897827
// https://github.com/facebook/create-react-app/pull/11752
Expand Down Expand Up @@ -132,9 +134,19 @@ module.exports = {
// exclude them from the fallback
resourceRule.exclude.push(/\.(vert|frag|wav)$/);

const babelRule = oneOfRule.oneOf.find((r) =>
r.loader?.includes("babel"),
);

// add a new rule for collecting coverage
if (env === "development" && process.env.COVERAGE === "true") {
babelRule.options.plugins.push("istanbul");
}

return webpackConfig;
},
},

// craco plugins
plugins: [
{
Expand Down
88 changes: 74 additions & 14 deletions apps/scratch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,30 @@
"name": "app-scratch",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "PORT=3101 craco start",
"dev:coverage": "PORT=3101 COVERAGE=true craco start",
"build": "craco build",
"pretest": "shx rm -rf coverage/ .nyc_output/",
"test": "yarn pretest && playwright test && yarn posttest",
"test:local": "yarn pretest && SERVER_ALREADY_RUNS=true playwright test && yarn posttest",
"test:debug": "SERVER_ALREADY_RUNS=true playwright test --debug --project='iPad Mini landscape'",
"posttest": "nyc report",
"eject": "react-scripts eject",
"lint": "eslint '**/*.ts' '**/*.tsx' --ignore-pattern node_modules/",
"extract:i18n": "formatjs extract 'src/{components,sections}/**/*.{js,ts,tsx}' --format crowdin --out-file content/locales/en.json",
"compile:i18n": "formatjs compile-folder --ast --format crowdin content/locales content/compiled-locales",
"i18n": "yarn extract:i18n && yarn compile:i18n",
"prepublish": "node scripts/prepublish.mjs"
},
"dependencies": {
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.4",
"@craco/craco": "^7.1.0",
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@microbit/microbit-universal-hex": "^0.2.2",
"@playwright/test": "^1.48.1",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^12.1.5",
"@testing-library/user-event": "^13.5.0",
Expand All @@ -15,6 +34,7 @@
"@typescript-eslint/parser": "^8.6.0",
"arraybuffer-loader": "^1.0.8",
"autoprefixer": "^9.0.1",
"babel-plugin-istanbul": "^7.0.0",
"balance-text": "^3.3.1",
"bowser": "^2.11.0",
"buffer": "^6.0.3",
Expand All @@ -32,10 +52,13 @@
"get-user-media-promise": "1.1.4",
"immutable": "^4.3.7",
"js-base64": "^3.7.7",
"jszip": "^3.10.1",
"keymirror": "^0.1.1",
"lodash.defaultsdeep": "^4.6.1",
"omggif": "^1.0.10",
"papaparse": "^5.4.1",
"playwright": "^1.48.1",
"playwright-test-coverage": "^1.2.12",
"postcss": "^8.4.47",
"postcss-import": "^12.0.0",
"postcss-loader": "^4.3.0",
Expand All @@ -50,8 +73,9 @@
"react-intl-redux": "^2.4.1",
"react-modal": "^3.16.1",
"react-popover": "^0.5.10",
"react-redux": "^5.0.1",
"react-redux": "^8.1.3",
"react-responsive": "^5.0.0",
"react-router-dom": "^6.27.0",
"react-scripts": "5.0.1",
"react-style-proptype": "^3.2.2",
"react-tabs": "^2.3.0",
Expand All @@ -68,6 +92,7 @@
"scratch-storage": "^2.3.255",
"scratch-svg-renderer": "^2.4.15",
"scratch-vm": "patch:scratch-vm@npm%3A4.6.29#~/.yarn/patches/scratch-vm-npm-4.6.29-f3a8bb62d5.patch",
"shx": "^0.3.4",
"stream-browserify": "^3.0.0",
"style-loader": "^4.0.0",
"to-style": "^1.3.3",
Expand All @@ -83,18 +108,6 @@
"@types/react": "16.14.61",
"babel-preset-react-app@npm:^10.0.1": "patch:babel-preset-react-app@npm%3A10.0.1#~/.yarn/patches/babel-preset-react-app-npm-10.0.1-a9a19b630a.patch"
},
"scripts": {
"dev": "craco start",
"build": "craco build",
"test": "craco test",
"test:cov": "craco test --coverage --watchAll=false --testPathIgnorePatterns=src/scratch",
"eject": "react-scripts eject",
"lint": "eslint '**/*.ts' '**/*.tsx' --ignore-pattern node_modules/",
"extract:i18n": "formatjs extract 'src/{components,sections}/**/*.{js,ts,tsx}' --format crowdin --out-file content/locales/en.json",
"compile:i18n": "formatjs compile-folder --ast --format crowdin content/locales content/compiled-locales",
"i18n": "yarn extract:i18n && yarn compile:i18n",
"prepublish": "node scripts/prepublish.mjs"
},
"eslintConfig": {
"extends": [
"react-app",
Expand Down Expand Up @@ -122,6 +135,52 @@
"__tests__",
"\\.d\\.ts$",
"\\.spec\\.(t|j)sx?$"
],
"moduleNameMapper": {
"@scratch-submodule/(.*)": "<rootDir>/src/scratch/$1",
"!ify-loader!(.*)": "<rootDir>/node_modules/$1",
"!arraybuffer-loader!(.*)": "<rootDir>/src/tests/binary.ts",
"!raw-loader!(.*)": "<rootDir>/src/tests/binary.ts",
"!base64-loader!(.*)": "<rootDir>/src/tests/binary.ts"
}
},
"nyc": {
"all": true,
"parserPlugins": [
"typescript",
"jsx",
"asyncGenerators",
"bigInt",
"classProperties",
"classPrivateProperties",
"classPrivateMethods",
"dynamicImport",
"importMeta",
"numericSeparator",
"objectRestSpread",
"optionalCatchBinding",
"topLevelAwait"
],
"extensions": [
".ts",
".tsx"
],
"include": [
"src/**/*"
],
"exclude": [
"**/*.config.js",
"**/*.d.ts",
"**/node_modules/**/*",
"**/__mocks__/**/*",
"**/__tests__/**/*",
"src/scratch/**/*",
"src/setupTests.ts",
"src/tests/**/*"
],
"reporter": [
"lcov",
"text"
]
},
"packageManager": "[email protected]",
Expand All @@ -147,6 +206,7 @@
"@types/react-responsive": "^8.0.8",
"@types/react-tabs": "^2.3.0",
"@types/react-virtualized": "^9",
"@types/wav-encoder": "^1"
"@types/wav-encoder": "^1",
"nyc": "^17.1.0"
}
}
37 changes: 37 additions & 0 deletions apps/scratch/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { defineConfig, devices, PlaywrightTestConfig } from "@playwright/test";

const config: PlaywrightTestConfig = {
// ignore the scratch submodules
testIgnore: "**src/scratch/**/*",

projects: [
{
name: "Desktop",
use: devices["Desktop Chrome"],
},
{
name: "iPad Mini landscape",
use: {
...devices["iPad Mini landscape"],
// override the browser, webkit does not seem to support audio in playwright
browserName: "chromium",
},
},
],

use: {
baseURL: "http://localhost:3101",
},
};

// eslint-disable-next-line no-undef
if (!process.env.SERVER_ALREADY_RUNS) {
config.webServer = {
// Run your local dev server before starting the tests.
command: "yarn dev:coverage",
url: "http://localhost:3101",
timeout: 120 * 1000,
};
}

export default defineConfig(config);
Loading

0 comments on commit 1821fb4

Please sign in to comment.