From b4c1969c3aae8739861c85400280da4cb101af97 Mon Sep 17 00:00:00 2001 From: Tero Virtanen <105207219+terovirtanen@users.noreply.github.com> Date: Mon, 18 Mar 2024 13:59:31 +0200 Subject: [PATCH] build: remove useless pipelines OH-67 (#201) * build: remove useless pipeline files OH-67 * build: sonarcloud configuration exclude pipelines -folder * chore: pipeline info to readme --- README.md | 26 +++++- azure-pipelines-devtest.yml | 34 ------- azure-pipelines-master.yml | 36 -------- azure-pipelines-pull-request.yml | 33 ------- azure-pipelines-release.yml | 37 -------- azure-pipelines-stageprod.yml | 28 ------ azure-pipelines.yml | 151 ------------------------------- sonar-project.properties | 2 +- 8 files changed, 26 insertions(+), 321 deletions(-) delete mode 100644 azure-pipelines-devtest.yml delete mode 100644 azure-pipelines-master.yml delete mode 100644 azure-pipelines-pull-request.yml delete mode 100644 azure-pipelines-release.yml delete mode 100644 azure-pipelines-stageprod.yml delete mode 100644 azure-pipelines.yml diff --git a/README.md b/README.md index 60617045..bb5cdd82 100644 --- a/README.md +++ b/README.md @@ -146,12 +146,36 @@ pre-commit run --all-files ## Commit message format -New commit messages must adhere to the [Conventional Commits](https://www.conventionalcommits.org/) +!!!Note New commit messages must adhere to the [Conventional Commits](https://www.conventionalcommits.org/) specification, and line length is limited to 72 characters. When [`pre-commit`](https://pre-commit.com/) is in use, [`commitlint`](https://github.com/conventional-changelog/commitlint) checks new commit messages for the correct format. +## Release + +### Publish to Dev environment + +#### Review environment + +New commit to PR will trigger review pipeline. Review pipeline builds application and deploys a dynamic environment to the Openshift dev. The review environment can be used to verify PR. + +#### Dev environment + +Deployment to dev environment is handled automatically from master branch. Updates to master branch triggers +azure pipeline that will run tests, build and deploy to dev environment hosted by red hat openshift. +Currently azure-pipeline is configured directly from version control, but red hat openshift configuration resides in openshift cluster. + +### Release to Test, Stage and Production environments + +Release is done by [release-please](https://helsinkisolutionoffice.atlassian.net/wiki/spaces/DD/pages/8278966368/Releases+with+release-please). +It creates release PR based on commits messages. Merge of the PR will trigger a release pipeline that build and deploys to stage and test environments automatically. + +Release-please update the package.json version number automatically and it is included to release PR. + +#### Publish to production environments +Publishing to production requires manual approval in the DevOps release pipeline. + ## Importing data Currently, importing *resources* from Helsinki metropolitan area unit registry (TPREK) is supported. Import all resources from [TPREK API](https://www.hel.fi/palvelukarttaws/restpages/ver4.html) by diff --git a/azure-pipelines-devtest.yml b/azure-pipelines-devtest.yml deleted file mode 100644 index c4543bf8..00000000 --- a/azure-pipelines-devtest.yml +++ /dev/null @@ -1,34 +0,0 @@ -# Continuous integration (CI) triggers cause a pipeline to run whenever you push -# an update to the specified branches or you push specified tags. -trigger: - branches: - include: - - master - paths: - exclude: - - README.md - -# Pull request (PR) triggers cause a pipeline to run whenever a pull request is -# opened with one of the specified target branches, or when updates are made to -# such a pull request. -# -# GitHub creates a new ref when a pull request is created. The ref points to a -# merge commit, which is the merged code between the source and target branches -# of the pull request. -# -# Opt out of pull request validation -pr: none - -# By default, use self-hosted agents -pool: Default - -resources: - repositories: - # Azure DevOps repository - - repository: hauki-pipelines - type: git - # project/repository - name: hauki/hauki-pipelines - -extends: - template: azure-pipelines-build-hauki-api-devtest.yml@hauki-pipelines diff --git a/azure-pipelines-master.yml b/azure-pipelines-master.yml deleted file mode 100644 index 01da00f8..00000000 --- a/azure-pipelines-master.yml +++ /dev/null @@ -1,36 +0,0 @@ -# File: hauki/azure-pipelines.yml - -# Continuous integration (CI) triggers cause a pipeline to run whenever you push -# an update to the specified branches or you push specified tags. -trigger: - branches: - include: - - master - paths: - exclude: - - README.md - -# Pull request (PR) triggers cause a pipeline to run whenever a pull request is -# opened with one of the specified target branches, or when updates are made to -# such a pull request. -# -# GitHub creates a new ref when a pull request is created. The ref points to a -# merge commit, which is the merged code between the source and target branches -# of the pull request. -# -# Opt out of pull request validation -pr: none - -# By default, use self-hosted agents -pool: Default - -resources: - repositories: - # Azure DevOps repository - - repository: hauki-pipelines - type: git - # project/repository - name: hauki/hauki-pipelines - -extends: - template: azure-pipelines-hauki-api-master.yml@hauki-pipelines diff --git a/azure-pipelines-pull-request.yml b/azure-pipelines-pull-request.yml deleted file mode 100644 index 84fc3d67..00000000 --- a/azure-pipelines-pull-request.yml +++ /dev/null @@ -1,33 +0,0 @@ -# File: hauki/azure-pipelines.yml - -# Continuous integration (CI) triggers cause a pipeline to run whenever you push -# an update to the specified branches or you push specified tags. -# -# Opt out of CI triggers -trigger: none - -# Pull request (PR) triggers cause a pipeline to run whenever a pull request is -# opened with one of the specified target branches, or when updates are made to -# such a pull request. -# -# GitHub creates a new ref when a pull request is created. The ref points to a -# merge commit, which is the merged code between the source and target branches -# of the pull request. -pr: - branches: - include: - - master - -# By default, use self-hosted agents -pool: Default - -resources: - repositories: - # Azure DevOps repository - - repository: hauki-pipelines - type: git - # project/repository - name: hauki/hauki-pipelines - -extends: - template: azure-pipelines-hauki-api-pull-request.yml@hauki-pipelines diff --git a/azure-pipelines-release.yml b/azure-pipelines-release.yml deleted file mode 100644 index 187c4531..00000000 --- a/azure-pipelines-release.yml +++ /dev/null @@ -1,37 +0,0 @@ -# File: hauki/azure-pipelines.yml - -# Continuous integration (CI) triggers cause a pipeline to run whenever you push -# an update to the specified branches or you push specified tags. -trigger: - branches: - include: - - release/* - - refs/tags/* - paths: - exclude: - - README.md - -# Pull request (PR) triggers cause a pipeline to run whenever a pull request is -# opened with one of the specified target branches, or when updates are made to -# such a pull request. -# -# GitHub creates a new ref when a pull request is created. The ref points to a -# merge commit, which is the merged code between the source and target branches -# of the pull request. -# -# Opt out of pull request validation -pr: none - -# By default, use self-hosted agents -pool: Default - -resources: - repositories: - # Azure DevOps repository - - repository: hauki-pipelines - type: git - # project/repository - name: hauki/hauki-pipelines - -extends: - template: azure-pipelines-hauki-api-release.yml@hauki-pipelines diff --git a/azure-pipelines-stageprod.yml b/azure-pipelines-stageprod.yml deleted file mode 100644 index fbf9c1dc..00000000 --- a/azure-pipelines-stageprod.yml +++ /dev/null @@ -1,28 +0,0 @@ -# Continuous integration (CI) triggers cause a pipeline to run whenever you push -# an update to the specified branches or you push specified tags. -trigger: none - -# Pull request (PR) triggers cause a pipeline to run whenever a pull request is -# opened with one of the specified target branches, or when updates are made to -# such a pull request. -# -# GitHub creates a new ref when a pull request is created. The ref points to a -# merge commit, which is the merged code between the source and target branches -# of the pull request. -# -# Opt out of pull request validation -pr: none - -# By default, use self-hosted agents -pool: Production - -resources: - repositories: - # Azure DevOps repository - - repository: hauki-pipelines - type: git - # project/repository - name: hauki/hauki-pipelines - -extends: - template: azure-pipelines-build-hauki-api-stageprod.yml@hauki-pipelines diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 34d8e1b9..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,151 +0,0 @@ -# Docker -# Build a Docker image -# https://docs.microsoft.com/azure/devops/pipelines/languages/docker -# https://dev.to/n3wt0n/container-image-promotion-across-environments-yaml-1ca6 - -trigger: - batch: true - -resources: -- repo: self - -variables: - tag: '$(Build.SourceVersion)' - branch: '$(Build.SourceBranchName)' - ImageName: 'hauki' - azureSubscription: HKI-kanslia-standalone - appName: hauki - containerRegistry: registry.hub.docker.com - tag_postfix: 'apm' - ${{ if ne(variables['Build.SourceBranchName'], 'master') }}: - tags: | - $(tag) - $(tag)_$(tag_postfix) - $(branch)_latest - $(branch)_latest_$(tag_postfix) - ${{ if eq(variables['Build.SourceBranchName'], 'master') }}: - tags: | - $(tag) - $(tag)_$(tag_postfix) - latest - latest_$(tag_postfix) -pool: - vmImage: 'ubuntu-latest' - -stages: -- stage: Build - displayName: Build the images - jobs: - - job: Build - displayName: Build - steps: - - script: | - echo 'Running in workspace $(Pipeline.Workspace)' - echo 'Build.SourceBranchName: $(branch)' - echo 'Build.SourceVersion: $(tag)' - echo 'Build.SourcesDirectory: $(Build.SourcesDirectory)' - echo 'Build.ArtifactStagingDirectory: $(build.artifactstagingdirectory)' - echo 'Tags: $(tags)' - - task: DockerCompose@0 - displayName: Build images - inputs: - dockerComposeCommand: build - dockerComposeFile: '$(Build.SourcesDirectory)/docker-compose.yml' - - task: Docker@2 - displayName: Build APM enhanced image - inputs: - repository: '$(ImageName)' - command: build - tags: 'apm' - Dockerfile: deploy/elastic_apm_injection/Dockerfile - arguments: --build-arg BASE_IMAGE=$(ImageName) - - script: | - docker tag hauki_dev:latest hauki:dev_latest - docker rmi hauki_dev - displayName: - - task: Docker@2 - displayName: Save hauki image repository to TAR - inputs: - repository: '$(ImageName)' - command: save - arguments: '--output $(build.artifactstagingdirectory)/$(ImageName).image.tar $(ImageName)' - addPipelineData: false - - publish: $(build.artifactstagingdirectory) - artifact: ContainerImages -- stage: Test - displayName: Test - jobs: - - job: Test - displayName: Test the dev image - steps: - - task: DownloadPipelineArtifact@2 - displayName: Download hauki repository TAR - inputs: - artifact: ContainerImages - - task: Docker@2 - displayName: Load hauki repository from TAR - inputs: - command: load - arguments: '--input $(Pipeline.Workspace)/$(ImageName).image.tar' - - script: | - docker tag hauki:dev_latest hauki_dev:latest - displayName: Add hauki_dev name back to image for docker-compose - - task: DockerCompose@0 - displayName: Run tests - inputs: - dockerComposeCommand: run dev test - dockerComposeFile: '$(Build.SourcesDirectory)/docker-compose.yml' -- stage: Push - displayName: Push - jobs: - - job: Push - displayName: Push deploy image to registry - steps: - - task: DownloadPipelineArtifact@2 - displayName: Download image repo TAR - inputs: - artifact: ContainerImages - - task: Docker@2 - displayName: Load image repository from TAR - inputs: - command: load - arguments: '--input $(Pipeline.Workspace)/$(ImageName).image.tar' - - script: | - docker tag $(ImageName):latest helsinki/$(ImageName):$(tag) - docker tag $(ImageName):apm helsinki/$(ImageName):$(tag)_$(tag_postfix) - displayName: Retag image for Helsinki repo with commit hash - - script: | - docker tag $(ImageName):latest helsinki/$(ImageName):latest - docker tag $(ImageName):apm helsinki/$(ImageName):latest_$(tag_postfix) - displayName: Retag image for Helsinki repo with latest - condition: eq(variables['branch'], 'master') - - script: | - docker tag $(ImageName):latest helsinki/$(ImageName):$(branch)_latest - docker tag $(ImageName):apm helsinki/$(ImageName):$(branch)_latest_$(tag_postfix) - displayName: Retag image for Helsinki repo with branch name - condition: ne(variables['branch'], 'master') - - task: Docker@2 - displayName: Push image to Docker hub - inputs: - containerRegistry: Docker hub upload-hauki - repository: helsinki/$(ImageName) - command: push - tags: $(tags) -- stage: Deploy - displayName: Deploy to Openshift - jobs: - - job: Update - displayName: Update OC Imagestream - steps: - - task: oc-cmd@2 - displayName: Add OC tag to PR image - inputs: - openshiftService: Azure OpenShift-hauki - cmd: 'tag docker.io/helsinki/hauki:$(tag)_$(tag_postfix) hauki-backend:HAUKI-91-models_latest' - condition: eq(variables['branch'], 'HAUKI-91-models') - - task: oc-cmd@2 - displayName: Add OC tag to latest image - inputs: - openshiftService: Azure OpenShift-hauki - cmd: 'tag docker.io/helsinki/hauki:$(tag)_$(tag_postfix) hauki-backend:latest' - condition: eq(variables['branch'], 'master') diff --git a/sonar-project.properties b/sonar-project.properties index 856e124e..46ba4fcb 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -3,4 +3,4 @@ sonar.organization=city-of-helsinki sonar.python.version=3.9 sonar.python.coverage.reportPaths=coverage.xml sonar.test.inclusions=**/tests/**/* -sonar.exclusions=**/tests/**/*,**/migrations/*,commitlint.config.js,**/load-tests/**/* +sonar.exclusions=**/tests/**/*,**/migrations/*,commitlint.config.js,**/load-tests/**/*,pipelines/**