diff --git a/devops-pipelines/backend/backend-pr-build-and-test.yml b/devops-pipelines/backend/backend-pr-build-and-test.yml index 7a31b6ad5..ac382fefb 100644 --- a/devops-pipelines/backend/backend-pr-build-and-test.yml +++ b/devops-pipelines/backend/backend-pr-build-and-test.yml @@ -18,11 +18,19 @@ variables: value: '10.0.*' - name: testResultsDirectory value: "$(Agent.TempDirectory)/TestResults" + - name: prSourceBranch + value: $[variables['System.PullRequest.SourceBranch']] + - name: prTargetBranch + value: $[variables['System.PullRequest.TargetBranch']] pool: "LACC PreProd Pool" stages: - stage: Build_And_Test_Backend + condition: not(and( + eq(variables.prSourceBranch, 'development' ), + eq(variables.prTargetBranch, 'main') + )) displayName: "Build, Test & Package" jobs: - job: Package_NuGet diff --git a/devops-pipelines/tag-repo.yaml b/devops-pipelines/tag-repo.yaml new file mode 100644 index 000000000..cc325a594 --- /dev/null +++ b/devops-pipelines/tag-repo.yaml @@ -0,0 +1,73 @@ +trigger: + branches: + include: + - main + +pr: + branches: + include: + - main + +variables: + - group: lacc-deployment-global + - name: buildReason + value: $[variables['Build.Reason']] + +pool: "LaCC PreProd Pool" + +steps: + - checkout: self + persistCredentials: true + + - script: | + set -euo pipefail + + if [[ ! "$(releaseVersion)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "##vso[task.logissue type=error]The value of variable releaseVersion: $(releaseVersion) is not a valid semantic version. Expected format: MAJOR.MINOR.PATCH." + exit 1 + fi + + newTag="v$(releaseVersion)" + + # get the highest release tag from origin + # ignore peeled references produced for annotated tags + latestTag=$(git ls-remote --tags origin 'refs/tags/v*' | + awk '$2 !~ /\^\{\}$/ {sub("refs/tags/", "", $2); print $2}' | + sort -V | + tail -n 1) + + if [[ -z "$latestTag" ]]; then + echo "##vso[task.logissue type=warning]No release tags found in the remote repository." + else + echo "Latest remote tag: $latestTag" + echo "New release tag: $newTag" + + # validate the latest remote tag format + if [[ ! "$latestTag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "##vso[task.logissue type=error]The latest tag found in the remote repository has an unexpected format: $latestTag. Expected format: vMAJOR.MINOR.PATCH." + exit 1 + fi + + # fail if newTag is less than or equal to latestTag. + highestVersion=$(printf '%s\n%s\n' "$latestTag" "$newTag" | sort -V | tail -n 1) + + if [[ "$highestVersion" == "$latestTag" ]]; then + echo "##vso[task.logissue type=error]The semver value of variable releaseVersion: $(releaseVersion) must be greater than ${latestTag#v}." + exit 1 + fi + fi + + echo "The respository will be tagged with the new release version $newTag" + echo "##vso[task.setvariable variable=newTag;]$newTag" + displayName: "Validate releaseVersion Tag" + + - script: | + set -euo pipefail + + # overwrite any local tags. We are only interested in the remote: + git tag -f $(newTag) + + git push origin refs/tags/$(newTag) + # only tag repo on merge to main: + condition: and(succeeded(), eq(variables.buildReason, 'IndividualCI')) + displayName: "Tag Repository" diff --git a/devops-pipelines/ui/ui-pr-build-and-test.yml b/devops-pipelines/ui/ui-pr-build-and-test.yml index fca90c3cc..029e3e7d3 100644 --- a/devops-pipelines/ui/ui-pr-build-and-test.yml +++ b/devops-pipelines/ui/ui-pr-build-and-test.yml @@ -18,9 +18,17 @@ variables: value: ui-spa - name: covDir value: "coverage" + - name: prSourceBranch + value: $[variables['System.PullRequest.SourceBranch']] + - name: prTargetBranch + value: $[variables['System.PullRequest.TargetBranch']] stages: - stage: Build_and_Test_UI + condition: not(and( + eq(variables.prSourceBranch, 'development' ), + eq(variables.prTargetBranch, 'main') + )) displayName: "Build & Test UI SPA" jobs: - job: Build_and_Test @@ -143,3 +151,16 @@ stages: inputs: summaryFileLocation: "$(workingDir)/$(covDir)/merged/Cobertura.xml" failIfCoverageEmpty: true + + # On PR development -> main, run the E2E tests in dev + - stage: Run_E2E_tests + condition: and( + eq(variables.prSourceBranch, 'development' ), + eq(variables.prTargetBranch, 'main' ) + ) + dependsOn: [] + displayName: "Run E2E Test on Dev" + jobs: + - template: ../templates/e2e-playwright-test-job.yml + parameters: + environment: "dev"