Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CI #68

Merged
merged 6 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
{
files: [
'./.eslintrc.js',
'./.percy.js',
'./.prettierrc.js',
'./.stylelintrc.js',
'./.template-lintrc.js',
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ jobs:
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Test
run: yarn test
run: yarn percy exec -- ember test
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
22 changes: 22 additions & 0 deletions .percy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
version: 2,
snapshot: {
widths: [375, 1280],

minHeight: 1024,
percyCSS: '',
disableShadowDOM: false,
},

discovery: {
allowedHostnames: [],
disallowedHostnames: [],
networkIdleTimeout: 100,
},

upload: {
files: '**/*.{png,jpg,jpeg}',
ignore: '',
stripExtensions: false,
},
};
18 changes: 3 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,11 @@ Make use of the many generators for code, try `ember help generate` for more det
* `ember test`
* `ember test --server`

#### Mesh snapshots
**Update Percy snaphost**

The [text-maker](https://github.com/romgere/text2stl/blob/master/app/services/text-maker.ts) service's unit tests use mesh snapshot to test the service works as expected.
Run `yarn percy exec:start`, then run `ember test` or `ember test --server` & visit http://127.0.0.1:4200/tests?filter=Acceptance%20%7C%20visual.

If the service is updated (aka. when the generated mesh changes) the test will break.

~~To fix the tests, new mesh snapshots has to be generated. To generate the new snapshot use the command :~~

~~`yarn generate:snapshot`~~

~~Warning: Don't run this command to fix tests if no modifications was made on `text-maker` service (or `three` deps update) or if you don't know why you run it (generating new snapshots will generate new UUID for mesh & create new useless file diffs)~~

**No longer work with node 14**

Mesh snapshot need to be manualy updated, see console, when some mesh tests are failing...

Easy way to re-generate snaptshot is to naviate to [127.0.0.1:4200/tests?filter=it generate mesh according to snapshots#download_fixture](127.0.0.1:4200/tests?filter=it generate mesh according to snapshots#download_fixture) & download all file in `tests/fixtures/meshs/`snapshots/
Note: You'll need `PERCY_TOKEN` variable defined in your env.

### Linting

Expand Down
1 change: 1 addition & 0 deletions app/components/three-preview.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
renderer=(component 'three-preview/renderer'
mesh=@mesh
parentSize=@parentSize
nearCamera=@nearCamera
)
size=(component 'three-preview/size'
mesh=@mesh
Expand Down
12 changes: 6 additions & 6 deletions app/controllers/app/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { inject as service } from '@ember/service';
import FontManagerService from 'text2stl/services/font-manager';
import TextMakerService from 'text2stl/services/text-maker';
import STLExporterService from 'text2stl/services/stl-exporter';
import CounterService from 'text2stl/services/counter';
// import CounterService from 'text2stl/services/counter';
import { tracked } from '@glimmer/tracking';
import { trackedFunction } from 'ember-resources/util/function';
import { Registry as Services } from '@ember/service';
Expand Down Expand Up @@ -34,17 +34,17 @@ export default class GeneratorController extends Controller {

@service declare intl: IntlService;

@service('counter') declare counterService: CounterService;
// @service('counter') declare counterService: CounterService;

@service declare router: Services['router'];

declare model: RouteModel<ApplicationRoute>;

_gtag = gtag;

get counter() {
return this.counterService.counter;
}
// get counter() {
// return this.counterService.counter;
// }

font = trackedFunction(this, async () => {
return this.model.customFont
Expand Down Expand Up @@ -88,7 +88,7 @@ export default class GeneratorController extends Controller {
value: this.model.type,
});

this.counterService.updateCounter();
// this.counterService.updateCounter();
this.stlExporter.downloadMeshAsSTL(mesh);
}

Expand Down
4 changes: 3 additions & 1 deletion app/models/text-maker-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ interface TextMakerAdditionnalSettings {
variantName: Variant;
}

export type TextMakerSettingsParameters = TextMakerParameters & TextMakerAdditionnalSettings;

interface QPSerializable {
serialize(): string;
deserialize(json: string): void;
Expand Down Expand Up @@ -123,7 +125,7 @@ export default class TextMakerSettings implements TextMakerParameters, QPSeriali
@tracked supportPadding: SupportPaddingSettings;
@tracked handleSettings: HandleSettings;

constructor(args: TextMakerParameters & TextMakerAdditionnalSettings) {
constructor(args: TextMakerSettingsParameters) {
this.variantName = args.variantName;
this.fontName = args.fontName;
this.text = args.text ?? textMakerDefault.text;
Expand Down
6 changes: 3 additions & 3 deletions app/modifiers/three-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface ThreeRendererModifierSignature {
export default class ThreeRendererModifier extends Modifier<ThreeRendererModifierSignature> {
scene?: THREE.Scene;
camera?: THREE.PerspectiveCamera;
renderer?: THREE.WebGLRenderer;
renderer?: THREE.WebGLRenderer | THREE.WebGL1Renderer;
mesh?: THREE.Mesh;

controls?: OrbitControls;
Expand Down Expand Up @@ -64,8 +64,8 @@ export default class ThreeRendererModifier extends Modifier<ThreeRendererModifie
this.camera = new THREE.PerspectiveCamera(75);
this.camera.position.set(
0,
this.namedArgs.nearCamera ? 50 : 400,
this.namedArgs.nearCamera ? 70 : 300,
this.namedArgs.nearCamera ? 250 : 400,
this.namedArgs.nearCamera ? 150 : 300,
);
this.scene.add(this.camera);

Expand Down
6 changes: 3 additions & 3 deletions app/templates/app/generator.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
>

<div slot="footer">
{{#if this.counter}}
{{!-- {{#if this.counter}}
<calcite-notice open icon="information">
<div slot="message">
{{t 'stl_counter' count=this.counter}}
</div>
</calcite-notice>
{{/if}}
{{/if}} --}}

<calcite-button
width="full"
Expand All @@ -68,7 +68,7 @@


<calcite-panel>
<ThreePreview @mesh={{this.mesh.value}} @parentSize={{true}} as |preview|>
<ThreePreview @mesh={{this.mesh.value}} @parentSize={{true}} @nearCamera={{true}} as |preview|>

<div id="three-preview-container">
<preview.renderer />
Expand Down
4 changes: 2 additions & 2 deletions app/templates/app/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<LangSwitcher slot="back" width="full" @appearance="outline-fill" />

<calcite-button {{on "click" this.gotoGenerator}} slot="primary" width="full">
<calcite-button {{on "click" this.gotoGenerator}} slot="primary" width="full" data-test-generator>
{{t "index_page.button"}}
</calcite-button>
</calcite-modal>
</calcite-modal>
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"start": "ember serve",
"test": "concurrently \"npm:lint\" \"npm:test:*\" --names \"lint,test:\"",
"test:ember": "ember test",
"generate:snapshot": "ts-node -r esm tests/fixtures/script/generate.ts",
"generate:type_img": "misc/text_type/generate_logo.sh"
},
"devDependencies": {
Expand All @@ -39,6 +38,8 @@
"@glimmer/component": "^1.1.2",
"@glimmer/tracking": "^1.1.2",
"@onehilltech/ember-cli-google-analytics": "^1.2.0",
"@percy/cli": "^1.27.3",
"@percy/ember": "^4.2.0",
"@types/ember__application": "^~4.0",
"@types/ember__array": "~4.0",
"@types/ember__component": "~4.0",
Expand Down Expand Up @@ -103,9 +104,6 @@
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-qunit": "^7.3.4",
"esm": "^3.2.25",
"jsdom": "^16.4.0",
"jsdom-global": "^3.0.2",
"loader.js": "^4.7.0",
"prettier": "^2.8.7",
"qunit": "^2.19.4",
Expand All @@ -116,7 +114,6 @@
"stylelint-prettier": "^3.0.0",
"tracked-built-ins": "^3.1.1",
"tracked-toolbox": "^1.2.2",
"ts-node": "^10.4.0",
"typescript": "^4.2.3",
"webpack": "^5.78.0"
},
Expand Down
Loading
Loading