From 50ccfa1433957c7b5e1e8f023d1355ed50010f97 Mon Sep 17 00:00:00 2001 From: dobromirts Date: Mon, 5 Aug 2024 16:30:09 +0300 Subject: [PATCH] build(ci): Add azure build pipeline --- azure-pipelines/azure-pipeline.yml | 130 ++++++++++++++++++++++ azure-pipelines/templates/template.yml | 144 +++++++++++++++++++++++++ 2 files changed, 274 insertions(+) create mode 100644 azure-pipelines/azure-pipeline.yml create mode 100644 azure-pipelines/templates/template.yml diff --git a/azure-pipelines/azure-pipeline.yml b/azure-pipelines/azure-pipeline.yml new file mode 100644 index 000000000..91151f073 --- /dev/null +++ b/azure-pipelines/azure-pipeline.yml @@ -0,0 +1,130 @@ +trigger: + branches: + include: + - master + - vnext + +# This pipeline is meant to build specific branches for deployment. It's not meant to be a part of PR validation. Ensure that this pipeline is reserved for deployment purposes. +pr: none + +name: $(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r) + +variables: + githubToken: # Add a GitHub token in Libraries + ReplacementText: '@infragistics/igniteui-angular-extras' + +jobs: +- job: CommonSteps + displayName: Common Steps for All Jobs + pool: + vmImage: ubuntu-latest + steps: + - checkout: self + clean: true + fetchTags: true + + - task: NodeTool@0 + displayName: Use Node 20.x + inputs: + versionSpec: 20.x + + - task: Npm@1 + displayName: npm cache clean + continueOnError: true + inputs: + command: custom + workingDir: $(Build.SourcesDirectory) + verbose: false + customCommand: cache clean --force + + - task: Npm@1 + displayName: npm cache verify + inputs: + command: custom + workingDir: $(Build.SourcesDirectory) + verbose: false + customCommand: cache verify + + - task: RegexReplace@3 + displayName: RegEx Find & Replace + inputs: + InputSearchPattern: | + projects/app-lob/src/app/grid-dynamic-chart-data/grid-dynamic-chart-data.module.ts + projects/app-lob/src/app/grid-dynamic-chart-data/grid-dynamic-chart-data.component.ts + projects/app-lob/src/app/app.module.ts + package.json + FindRegex: igniteui-angular-extras + ReplaceRegex: $(ReplacementText) + UseUTF8: false + + - task: Npm@1 + displayName: npm install + inputs: + workingDir: $(Build.SourcesDirectory) + verbose: false + + - task: CmdLine@2 + displayName: Clone submodule + inputs: + script: git clone --recurse-submodules https://github.com/IgniteUI/igniteui-live-editing-samples igniteui-live-editing-samples + workingDirectory: ${{ parameters.workingDir }} + + - task: PublishPipelineArtifact@1 + inputs: + targetPath: '$(Build.SourcesDirectory)' + artifact: 'source-code' + publishLocation: 'pipeline' + +- job: Job_1 + displayName: App CD Build + dependsOn: CommonSteps + pool: + vmImage: ubuntu-latest + steps: + - download: current + artifact: source-code + - template: template.yml + parameters: + customCommand: run generate-live-editing + workingDir: $(Build.SourcesDirectory) + submoduleDir: angular-demos + baseHref: /angular-demos/ + targetFolder: dist/app-lob + findRegex: angular-demos + npmBuildCommand: 'run build-ci' + +- job: Job_2 + displayName: App CRM Build + dependsOn: CommonSteps + pool: + vmImage: ubuntu-latest + steps: + - download: current + artifact: source-code + - template: template.yml + parameters: + customCommand: run generate-live-editing:app-crm + workingDir: $(Build.SourcesDirectory) + submoduleDir: angular-demos-crm + baseHref: /angular-demos-grid-crm/ + targetFolder: dist/app-crm + findRegex: angular-demos + npmBuildCommand: 'run build-ci:app-crm --loglevel verbose' + +- job: Job_3 + displayName: App LOB Build + dependsOn: CommonSteps + pool: + vmImage: ubuntu-latest + steps: + - download: current + artifact: source-code + - template: template.yml + parameters: + customCommand: run generate-live-editing:app-lob + workingDir: $(Build.SourcesDirectory) + submoduleDir: angular-demos-lob + baseHref: /angular-demos-lob/ + targetFolder: dist/app-lob + findRegex: angular-demos + npmBuildCommand: 'run build-ci:app-lob' diff --git a/azure-pipelines/templates/template.yml b/azure-pipelines/templates/template.yml new file mode 100644 index 000000000..4ea30be2c --- /dev/null +++ b/azure-pipelines/templates/template.yml @@ -0,0 +1,144 @@ +# template.yml +parameters: + - name: customCommand + type: string + - name: workingDir + type: string + - name: submoduleDir + type: string + - name: baseHref + type: string + - name: targetFolder + type: string + default: 'dist' + - name: findRegex + type: string + - name: npmBuildCommand + type: string + default: '' + - name: runCleanup + type: boolean + default: true + +steps: + # - task: CmdLine@2 + # displayName: Clone submodule + # inputs: + # script: git clone --recurse-submodules https://github.com/IgniteUI/igniteui-live-editing-samples igniteui-live-editing-samples + # workingDirectory: ${{ parameters.workingDir }} + + - task: CmdLine@2 + displayName: Staging - Git checkout branch + condition: eq(variables['Build.SourceBranchName'], 'vNext') + inputs: + script: git checkout vNext + workingDirectory: ${{ parameters.workingDir }}/igniteui-live-editing-samples + + - task: CmdLine@2 + displayName: Production - Git checkout branch + condition: and(eq(variables['Build.SourceBranchName'], 'master'), contains(variables['build.reason'], 'CI')) + inputs: + script: git checkout master + workingDirectory: ${{ parameters.workingDir }}/igniteui-live-editing-samples + + - script: | + sed -i 's/--configuration production/--base-href=${{ parameters.baseHref }} --configuration production/g' package.json + displayName: 'Update package.json file' + workingDirectory: ${{ parameters.workingDir }} + + - task: Npm@1 + displayName: generate live-editing + inputs: + command: custom + workingDir: ${{ parameters.workingDir }} + verbose: false + customCommand: ${{ parameters.customCommand }} + + - task: CmdLine@2 + displayName: Update to licensed igniteui-angular + inputs: + script: npx ng g @igniteui/angular-schematics:upgrade-packages --skip-install + workingDirectory: ${{ parameters.workingDir }} + + - task: Npm@1 + displayName: ${{ parameters.npmBuildCommand }} + inputs: + command: custom + workingDir: ${{ parameters.workingDir }} + verbose: false + customCommand: ${{ parameters.npmBuildCommand }} + + - task: CopyFiles@2 + displayName: Copy web.config + inputs: + SourceFolder: $(Build.SourcesDirectory) + Contents: web.config + TargetFolder: $(Build.SourcesDirectory)/${{ parameters.targetFolder }} + + - task: RegexReplace@3 + displayName: RegEx Find & Replace + inputs: + InputSearchPattern: $(Build.SourcesDirectory)/${{ parameters.targetFolder }}/web.config + FindRegex: ${{ parameters.findRegex }} + ReplaceRegex: ${{ parameters.submoduleDir }} + UseUTF8: false + + - task: PublishPipelineArtifact@1 + displayName: Publish Artifact + inputs: + targetPath: $(Build.SourcesDirectory)/${{ parameters.targetFolder }} + artifact: $(Build.SourceBranchName)-artifact + publishLocation: pipeline + + - task: Npm@1 + displayName: Staging - Repositorify Angular Demos and LOB Demos + condition: eq(variables['Build.SourceBranchName'], 'vNext') + inputs: + command: custom + workingDir: ${{ parameters.workingDir }} + verbose: false + customCommand: run repositoryfyAngularDemosLob + + - task: Npm@1 + displayName: Production - Repositorify Angular Demos + condition: and(eq(variables['Build.SourceBranchName'], 'master'), contains(variables['build.reason'], 'CI')) + inputs: + command: custom + workingDir: ${{ parameters.workingDir }} + verbose: false + customCommand: run repositoryfyAngularDemosLob:prod + + - task: CmdLine@2 + displayName: Stage changes + inputs: + script: git add . + workingDirectory: ${{ parameters.workingDir }}/igniteui-live-editing-samples/${{ parameters.submoduleDir }} + + - task: CmdLine@2 + displayName: 'Check if there are any changes to be committed' + inputs: + script: | + # Check for changes + changeCount=$(git status --porcelain | wc -l) + if [ "$changeCount" -eq 0 ]; then + echo "##vso[task.logissue type=warning]No changes to commit." + exit 0 + fi + workingDirectory: ${{ parameters.workingDir }}/igniteui-live-editing-samples/${{ parameters.submoduleDir }} + + + - task: CmdLine@2 + displayName: Commit changes + inputs: + script: git commit -m "Automated repository update" + workingDirectory: ${{ parameters.workingDir }}/igniteui-live-editing-samples/${{ parameters.submoduleDir }} + + - task: CmdLine@2 + displayName: Push changes + inputs: + script: git push + workingDirectory: ${{ parameters.workingDir }}/igniteui-live-editing-samples/${{ parameters.submoduleDir }} + + - task: PostBuildCleanup@4 + displayName: Clean Agent Directories + condition: eq('${{ parameters.runCleanup }}', 'true')