Skip to content

Commit

Permalink
chore(ci): use linux node (#2373)
Browse files Browse the repository at this point in the history
  • Loading branch information
shajz committed Oct 24, 2023
1 parent ddacab0 commit 4a8c040
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 115 deletions.
108 changes: 46 additions & 62 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
@Library('Lucca@v0.62.0') _
@Library('Lucca@v0.63.6') _

import hudson.Util
import fr.lucca.CI

ciBuildProperties script:this

node(label: CI.getSelectedNode(script:this)) {
notifyStartStats()

node(label: CI.getSelectedLinuxNode(script:this)) {
def projectTechnicalName = 'lucca-front'
def repoName = "lucca-front"

Expand All @@ -24,80 +22,66 @@ node(label: CI.getSelectedNode(script:this)) {

try {
timeout(time: 10, unit: 'MINUTES') {
loggableStage('Cleanup') {
// storybook static
if (fileExists('storybook')) {
dir('storybook') {
deleteDir()
}
}
}

loggableStage('Checkout') {
scmVars = checkout scm
}

loggableStage('Restore') {
npmCi()
}

if (!isPR) {
loggableStage('Qualif') {
// it must be buildable
bat "npm run build"
// it must break no test
bat "npm run jenkins-test"
// it must be lint compliant
bat "npm run lint"
npmCi()

npmScript(script: 'build')
npmScript(script: 'jenkins-test', skip: isPR)
npmScript(script: 'lint', skip: isPR)

def shouldDeploy = isPR || isRc || isMaster;

loggableStage('Deploy', !shouldDeploy) {
echo "deploying ${branchName}"
npmScript(script: 'build-storybook')
npmScript(script: 'build-compodoc')

// FIXME Deploy with windows node for now
stash(name: "storybook-static", includes: "storybook-static/**")
stash(name: "compodoc-static", includes: "compodoc-static/**")
node("windows") {
unstash(name: "storybook-static")
powershell "Remove-Item \\\\RBX1-SH1-TECH\\lucca-front\\${env.BRANCH_NAME}\\storybook -Recurse"
powershell "Copy-Item storybook-static \\\\RBX1-SH1-TECH\\lucca-front\\${env.BRANCH_NAME}\\storybook -Recurse"
unstash(name: "compodoc-static")
powershell "Remove-Item \\\\RBX1-SH1-TECH\\lucca-front\\${env.BRANCH_NAME}\\compodoc -Recurse"
powershell "Copy-Item compodoc-static \\\\RBX1-SH1-TECH\\lucca-front\\${env.BRANCH_NAME}\\compodoc -Recurse"
}
}

if (isPR || isRc || isMaster) {
loggableStage('Deploy') {
echo "deploying ${branchName}"
bat "npm run build-storybook"
bat "npm run build-compodoc"
powershell "Remove-Item \\\\RBX1-SH1-TECH\\lucca-front\\${branchName}\\storybook -Recurse"
powershell "Remove-Item \\\\RBX1-SH1-TECH\\lucca-front\\${branchName}\\compodoc -Recurse"
powershell "Copy-Item storybook-static \\\\RBX1-SH1-TECH\\lucca-front\\${branchName}\\storybook -Recurse"
powershell "Copy-Item compodoc-static \\\\RBX1-SH1-TECH\\lucca-front\\${branchName}\\compodoc -Recurse"
}

loggableStage('e2e') {
publishE2e(loggableStageName: 'e2e', slnFilepath: 'e2e\\LuccaFront.e2e.sln', framework: "net6.0")
archiveElements(e2e: true)
}

commentOnPR(
credentialsId: 'ux-comment-token',
body: ":woman_cook: https://lucca-front.lucca.tech/${branchName}/storybook",
repoName: projectTechnicalName,
skip: !isPR
)
loggableStage('e2e', !shouldDeploy) {
publishE2e(loggableStageName: 'e2e', slnFilepath: 'e2e/LuccaFront.e2e.sln', framework: "net6.0")
archiveElements(e2e: true)
}

if (!isPR) {
loggableStage('Publish') {
def version = env.BRANCH_NAME
commentOnPR(
credentialsId: 'ux-comment-token',
body: ":woman_cook: https://lucca-front.lucca.tech/${branchName}/storybook",
repoName: projectTechnicalName,
skip: !isPR
)

def iconsPackageJson = readFile(file: 'dist/icons/package.json');
def scssPackageJson = readFile(file: 'dist/scss/package.json');
def ngPackageJson = readFile(file: 'dist/ng/package.json');
loggableStage('Publish', isPR) {
def version = env.BRANCH_NAME

writeFile(file: 'dist/icons/package.json', text: iconsPackageJson.replaceAll('"\\*"', "\"${version}\""));
writeFile(file: 'dist/scss/package.json', text: scssPackageJson.replaceAll('"\\*"', "\"${version}\""));
writeFile(file: 'dist/ng/package.json', text: ngPackageJson.replaceAll('"\\*"', "\"${version}\""));
def iconsPackageJson = readFile(file: 'dist/icons/package.json');
def scssPackageJson = readFile(file: 'dist/scss/package.json');
def ngPackageJson = readFile(file: 'dist/ng/package.json');

publishNpmOnReleaseTag(publishFolder: 'dist/icons')
publishNpmOnReleaseTag(publishFolder: 'dist/scss')
publishNpmOnReleaseTag(publishFolder: 'dist/ng')
}
writeFile(file: 'dist/icons/package.json', text: iconsPackageJson.replaceAll('"\\*"', "\"${version}\""));
writeFile(file: 'dist/scss/package.json', text: scssPackageJson.replaceAll('"\\*"', "\"${version}\""));
writeFile(file: 'dist/ng/package.json', text: ngPackageJson.replaceAll('"\\*"', "\"${version}\""));

publishNpmOnReleaseTag(publishFolder: 'dist/icons')
publishNpmOnReleaseTag(publishFolder: 'dist/scss')
publishNpmOnReleaseTag(publishFolder: 'dist/ng')
}
}
} catch(err) {
println err
currentBuild.result = 'failure'
}

notifyEndStats()
}
74 changes: 22 additions & 52 deletions packages/ng/establishment/establishment-select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import { HttpClientModule } from '@angular/common/http';
import { discardPeriodicTasks, fakeAsync, tick } from '@angular/core/testing';
import { fireEvent, render, screen } from '@testing-library/angular';
import { RenderTemplateOptions, fireEvent, render, screen } from '@testing-library/angular';
import { createMock } from '@testing-library/angular/jest-utils';
import '@testing-library/jest-dom';
import userEvent from '@testing-library/user-event';
Expand Down Expand Up @@ -55,13 +55,25 @@ describe('establishment select', () => {
<span class="textfield-label">Establishment Multiple Select</span>
</label>`;

const rendererTemplateOptions: RenderTemplateOptions<LuEstablishmentSelectInputComponent> = {
imports: [LuEstablishmentSelectInputComponent, HttpClientModule],
componentProviders: [
{
provide: ALuEstablishmentService,
useValue: mockEstablishment,
},
{
provide: ALuLegalUnitService,
useValue: mockLegalUnit,
},
],
};

describe('Basic', () => {
it('should display dialog with a click on a lu select ', async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any

await render(testingStoryTemplate, {
imports: [LuEstablishmentSelectInputComponent, HttpClientModule],
});
await render(testingStoryTemplate, rendererTemplateOptions);

const luSelectElement = screen.getByTestId('lu-select');
await userEvent.click(luSelectElement);
Expand All @@ -74,19 +86,7 @@ describe('establishment select', () => {
discardPeriodicTasks();

// eslint-disable-next-line @typescript-eslint/no-explicit-any
await render(testingStoryTemplate, {
imports: [LuEstablishmentSelectInputComponent, HttpClientModule],
componentProviders: [
{
provide: ALuEstablishmentService,
useValue: mockEstablishment,
},
{
provide: ALuLegalUnitService,
useValue: mockLegalUnit,
},
],
});
await render(testingStoryTemplate, rendererTemplateOptions);
const luSelectElement = await screen.findByTestId('lu-select');

expect(luSelectElement).toBeInTheDocument();
Expand All @@ -101,9 +101,7 @@ describe('establishment select', () => {
}));

it('should check a11y', async () => {
await render(testingStoryTemplate, {
imports: [LuEstablishmentSelectInputComponent, HttpClientModule],
});
await render(testingStoryTemplate, rendererTemplateOptions);
const luSelectElement = screen.getByTestId('lu-select');

const results = await axe(luSelectElement);
Expand All @@ -114,9 +112,7 @@ describe('establishment select', () => {
describe('multiple', () => {
it('should display dialog with a click on a lu select ', async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await render(testingStoryTemplate, {
imports: [LuEstablishmentSelectInputComponent, HttpClientModule],
});
await render(testingStoryTemplate, rendererTemplateOptions);
const luSelectElement = screen.getByTestId('lu-select-multiple');
await userEvent.click(luSelectElement);
const dial = screen.getByRole('dialog');
Expand All @@ -125,19 +121,7 @@ describe('establishment select', () => {

it('should select all establishment', fakeAsync(async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await render(testingStoryTemplate, {
imports: [LuEstablishmentSelectInputComponent, HttpClientModule],
componentProviders: [
{
provide: ALuEstablishmentService,
useValue: mockEstablishment,
},
{
provide: ALuLegalUnitService,
useValue: mockLegalUnit,
},
],
});
await render(testingStoryTemplate, rendererTemplateOptions);

const luSelectElement = await screen.findByTestId('lu-select-multiple');
expect(luSelectElement).toBeInTheDocument();
Expand All @@ -153,19 +137,7 @@ describe('establishment select', () => {

it('should deselect all establishment', fakeAsync(async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await render(testingStoryTemplate, {
imports: [LuEstablishmentSelectInputComponent, HttpClientModule],
componentProviders: [
{
provide: ALuEstablishmentService,
useValue: mockEstablishment,
},
{
provide: ALuLegalUnitService,
useValue: mockLegalUnit,
},
],
});
await render(testingStoryTemplate, rendererTemplateOptions);
const luSelectElement = await screen.findByTestId('lu-select-multiple');
fireEvent.click(luSelectElement);
tick(300); // debouncetime du composant
Expand All @@ -181,9 +153,7 @@ describe('establishment select', () => {
}));

it('should check a11y', async () => {
await render(testingStoryTemplate, {
imports: [LuEstablishmentSelectInputComponent, HttpClientModule],
});
await render(testingStoryTemplate, rendererTemplateOptions);
const luSelectElement = screen.getByTestId('lu-select-multiple');
const results = await axe(luSelectElement);
expect(results).toHaveNoViolations(); // of course not
Expand Down
2 changes: 1 addition & 1 deletion packages/ng/form-field/form-field.component.scss
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@use '@lucca-front/scss/src/components/textfield';
@use '@lucca-front/scss/src/components/textField';

0 comments on commit 4a8c040

Please sign in to comment.