From df33616544aea800c626c6f04c35b1dae9c6b9bb Mon Sep 17 00:00:00 2001 From: Jens L Date: Thu, 28 May 2020 18:57:48 +0200 Subject: [PATCH 01/15] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..03fa44f81 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,29 @@ +# Docker +# Build a Docker image +# https://docs.microsoft.com/azure/devops/pipelines/languages/docker + +trigger: +- master + +resources: +- repo: self + +variables: + tag: '$(Build.BuildId)' + +stages: +- stage: Build + displayName: Build image + jobs: + - job: Build + displayName: Build + pool: + vmImage: 'ubuntu-latest' + steps: + - task: Docker@2 + displayName: Build an image + inputs: + command: build + dockerfile: '$(Build.SourcesDirectory)/Dockerfile' + tags: | + $(tag) \ No newline at end of file From cfc8d0a0f746f0a4bbcb1deb41518825f2b94210 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 28 May 2020 19:15:18 +0200 Subject: [PATCH 02/15] ci: migrate lint to az --- .github/workflows/ci-cleanup.yml | 38 ----------- azure-pipelines.yml | 109 ++++++++++++++++++++++++------- 2 files changed, 87 insertions(+), 60 deletions(-) delete mode 100644 .github/workflows/ci-cleanup.yml diff --git a/.github/workflows/ci-cleanup.yml b/.github/workflows/ci-cleanup.yml deleted file mode 100644 index 0d24155b0..000000000 --- a/.github/workflows/ci-cleanup.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: passbook-ci-cleanup -on: - - delete - -jobs: - delete-server: - runs-on: ubuntu-latest - steps: - - name: Delete docker tag - env: - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - run: curl - -u $DOCKER_USERNAME:$DOCKER_PASSWORD - -X "DELETE" - "https://hub.docker.com/v2/repositories/$DOCKER_USERNAME/passbook/tags/${GITHUB_REF##*/}/" - delete-gatekeeper: - runs-on: ubuntu-latest - steps: - - name: Delete docker tag - env: - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - run: curl - -u $DOCKER_USERNAME:$DOCKER_PASSWORD - -X "DELETE" - "https://hub.docker.com/v2/repositories/$DOCKER_USERNAME/passbook-gatekeeper/tags/${GITHUB_REF##*/}/" - delete-static: - runs-on: ubuntu-latest - steps: - - name: Delete docker tag - env: - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - run: curl - -u $DOCKER_USERNAME:$DOCKER_PASSWORD - -X "DELETE" - "https://hub.docker.com/v2/repositories/$DOCKER_USERNAME/passbook-static/tags/${GITHUB_REF##*/}/" diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 03fa44f81..dc01bfb97 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,29 +1,94 @@ -# Docker -# Build a Docker image -# https://docs.microsoft.com/azure/devops/pipelines/languages/docker - trigger: -- master + - master resources: -- repo: self + - repo: self variables: - tag: '$(Build.BuildId)' + POSTGRES_DB: passbook + POSTGRES_USER: passbook + POSTGRES_PASSWORD: "EK-5jnKfjrGRm<77" stages: -- stage: Build - displayName: Build image - jobs: - - job: Build - displayName: Build - pool: - vmImage: 'ubuntu-latest' - steps: - - task: Docker@2 - displayName: Build an image - inputs: - command: build - dockerfile: '$(Build.SourcesDirectory)/Dockerfile' - tags: | - $(tag) \ No newline at end of file + - stage: Lint + jobs: + - job: pylint + pool: + vmImage: 'ubuntu-latest' + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: '3.8' + - task: CmdLine@2 + inputs: + script: | + sudo pip install -U wheel pipenv + pipenv install --dev + - task: CmdLine@2 + inputs: + script: pipenv run pylint passbook + - job: black + pool: + vmImage: 'ubuntu-latest' + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: '3.8' + - task: CmdLine@2 + inputs: + script: | + sudo pip install -U wheel pipenv + pipenv install --dev + - task: CmdLine@2 + inputs: + script: pipenv run black --check passbook + - job: prospector + pool: + vmImage: 'ubuntu-latest' + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: '3.8' + - task: CmdLine@2 + inputs: + script: | + sudo pip install -U wheel pipenv + pipenv install --dev + pipenv install --dev prospector --skip-lock + - task: CmdLine@2 + inputs: + script: pipenv run prospector --check passbook + - job: bandit + pool: + vmImage: 'ubuntu-latest' + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: '3.8' + - task: CmdLine@2 + inputs: + script: | + sudo pip install -U wheel pipenv + pipenv install --dev + - task: CmdLine@2 + inputs: + script: pipenv run bandit -r passbook + - job: pyright + pool: + vmImage: ubuntu-latest + steps: + - task: UseNode@1 + - task: UsePythonVersion@0 + inputs: + versionSpec: '3.8' + - task: CmdLine@2 + inputs: + script: npm install -g pyright + - task: CmdLine@2 + inputs: + script: | + sudo pip install -U wheel pipenv + pipenv install --dev + - task: CmdLine@2 + inputs: + script: pipenv run pyright From 1ed7e900f270f243d851eb07765ad1f5ef2b5479 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 28 May 2020 19:29:28 +0200 Subject: [PATCH 03/15] ci: migrate unittests and coverage --- README.md | 26 +------------------ azure-pipelines.yml | 52 +++++++++++++++++++++++++++++++++++++- scripts/docker-compose.yml | 25 ++++++++++++++++++ 3 files changed, 77 insertions(+), 26 deletions(-) create mode 100644 scripts/docker-compose.yml diff --git a/README.md b/README.md index 731732beb..a77266825 100644 --- a/README.md +++ b/README.md @@ -50,31 +50,7 @@ pipenv sync -d ``` Since passbook uses PostgreSQL-specific fields, you also need a local PostgreSQL instance to develop. passbook also uses redis for caching and message queueing. -For these databases you can use [Postgres.app](https://postgresapp.com/) and [Redis.app](https://jpadilla.github.io/redisapp/) on macOS or use it via docker-comppose: - -```yaml -version: '3.7' - -services: - postgresql: - container_name: postgres - image: postgres:11 - volumes: - - db-data:/var/lib/postgresql/data - ports: - - 127.0.0.1:5432:5432 - restart: always - redis: - container_name: redis - image: redis - ports: - - 127.0.0.1:6379:6379 - restart: always - -volumes: - db-data: - driver: local -``` +For these databases you can use [Postgres.app](https://postgresapp.com/) and [Redis.app](https://jpadilla.github.io/redisapp/) on macOS or use it the docker-compose file in `scripts/docker-compose.yml`. To tell passbook about these databases, create a file in the project root called `local.env.yml` with the following contents: diff --git a/azure-pipelines.yml b/azure-pipelines.yml index dc01bfb97..0c5a9a8c4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -57,7 +57,7 @@ stages: pipenv install --dev prospector --skip-lock - task: CmdLine@2 inputs: - script: pipenv run prospector --check passbook + script: pipenv run prospector passbook - job: bandit pool: vmImage: 'ubuntu-latest' @@ -92,3 +92,53 @@ stages: - task: CmdLine@2 inputs: script: pipenv run pyright + - stage: Test + jobs: + - job: migrations + pool: + vmImage: 'ubuntu-latest' + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: '3.8' + - task: DockerCompose@0 + displayName: Run services + inputs: + dockerComposeFile: 'scripts/docker-compose.yml' + action: 'Run services' + buildImages: false + - task: CmdLine@2 + inputs: + script: | + sudo pip install -U wheel pipenv + pipenv install --dev + - task: CmdLine@2 + inputs: + script: pipenv run ./manage.py migrate + - job: coverage + pool: + vmImage: 'ubuntu-latest' + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: '3.8' + - task: DockerCompose@0 + displayName: Run services + inputs: + dockerComposeFile: 'scripts/docker-compose.yml' + action: 'Run services' + buildImages: false + - task: CmdLine@2 + inputs: + script: | + sudo pip install -U wheel pipenv + pipenv install --dev + - task: CmdLine@2 + inputs: + script: pipenv run ./scripts/coverage.sh + - task: CmdLine@2 + inputs: + script: pipenv run coverage xml + - task: CmdLine@2 + inputs: + script: bash <(curl -s https://codecov.io/bash) diff --git a/scripts/docker-compose.yml b/scripts/docker-compose.yml new file mode 100644 index 000000000..ed841bce5 --- /dev/null +++ b/scripts/docker-compose.yml @@ -0,0 +1,25 @@ +version: '3.7' + +services: + postgresql: + container_name: postgres + image: postgres:11 + volumes: + - db-data:/var/lib/postgresql/data + environment: + POSTGRES_DB: passbook + POSTGRES_USER: passbook + POSTGRES_PASSWORD: "EK-5jnKfjrGRm<77" + ports: + - 5432:5432 + restart: always + redis: + container_name: redis + image: redis + ports: + - 6379:6379 + restart: always + +volumes: + db-data: + driver: local From 4037a444eb827025504f9deb9e2fa4605c3c404f Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 28 May 2020 19:44:25 +0200 Subject: [PATCH 04/15] ci: migrate building --- .github/workflows/ci.yml | 200 --------------------------------------- azure-pipelines.yml | 44 +++++++++ 2 files changed, 44 insertions(+), 200 deletions(-) delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 3b76df232..000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,200 +0,0 @@ -name: passbook-ci -on: - - push -env: - POSTGRES_DB: passbook - POSTGRES_USER: passbook - POSTGRES_PASSWORD: "EK-5jnKfjrGRm<77" - -jobs: - # Linting - pylint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - uses: actions/setup-python@v1 - with: - python-version: '3.8' - - name: Install dependencies - run: sudo pip install -U wheel pipenv && pipenv install --dev - - name: Lint with pylint - run: pipenv run pylint passbook - black: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - uses: actions/setup-python@v1 - with: - python-version: '3.8' - - name: Install dependencies - run: sudo pip install -U wheel pipenv && pipenv install --dev - - name: Lint with black - run: pipenv run black --check passbook - prospector: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - uses: actions/setup-python@v1 - with: - python-version: '3.8' - - name: Install dependencies - run: sudo pip install -U wheel pipenv && pipenv install --dev && pipenv install --dev prospector --skip-lock - - name: Lint with prospector - run: pipenv run prospector - bandit: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - uses: actions/setup-python@v1 - with: - python-version: '3.8' - - name: Install dependencies - run: sudo pip install -U wheel pipenv && pipenv install --dev - - name: Lint with bandit - run: pipenv run bandit -r passbook - pyright: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - uses: actions/setup-node@v1 - - uses: actions/setup-python@v1 - with: - python-version: '3.8' - - name: Install pyright - run: npm install -g pyright - - name: Install dependencies - run: sudo pip install -U wheel pipenv && pipenv install --dev - - name: Lint with pyright - run: pipenv run pyright - # Actual CI tests - migrations: - needs: - - pylint - - black - - prospector - services: - postgres: - image: postgres:latest - env: - POSTGRES_DB: passbook - POSTGRES_USER: passbook - POSTGRES_PASSWORD: "EK-5jnKfjrGRm<77" - ports: - - 5432:5432 - redis: - image: redis:latest - ports: - - 6379:6379 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - uses: actions/setup-python@v1 - with: - python-version: '3.8' - - name: Install dependencies - run: sudo pip install -U wheel pipenv && pipenv install --dev - - name: Run migrations - run: pipenv run ./manage.py migrate - coverage: - needs: - - pylint - - black - - prospector - services: - postgres: - image: postgres:latest - env: - POSTGRES_DB: passbook - POSTGRES_USER: passbook - POSTGRES_PASSWORD: "EK-5jnKfjrGRm<77" - ports: - - 5432:5432 - redis: - image: redis:latest - ports: - - 6379:6379 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - uses: actions/setup-python@v1 - with: - python-version: '3.8' - - name: Install dependencies - run: sudo pip install -U wheel pipenv && pipenv install --dev - - name: Run coverage - run: pipenv run ./scripts/coverage.sh - - name: Create XML Report - run: pipenv run coverage xml - - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - # Build - build-server: - needs: - - migrations - - coverage - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Docker Login Registry - env: - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD - - name: Building Docker Image - run: docker build - --no-cache - -t beryju/passbook:${GITHUB_REF##*/} - -f Dockerfile . - - name: Push Docker Container to Registry - run: docker push beryju/passbook:${GITHUB_REF##*/} - build-gatekeeper: - needs: - - migrations - - coverage - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Docker Login Registry - env: - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD - - name: Building Docker Image - run: | - cd gatekeeper - docker build \ - --no-cache \ - -t beryju/passbook-gatekeeper:${GITHUB_REF##*/} \ - -f Dockerfile . - - name: Push Docker Container to Registry - run: docker push beryju/passbook-gatekeeper:${GITHUB_REF##*/} - build-static: - needs: - - migrations - - coverage - runs-on: ubuntu-latest - services: - postgres: - image: postgres:latest - env: - POSTGRES_DB: passbook - POSTGRES_USER: passbook - POSTGRES_PASSWORD: "EK-5jnKfjrGRm<77" - redis: - image: redis:latest - steps: - - uses: actions/checkout@v1 - - name: Docker Login Registry - env: - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD - - name: Building Docker Image - run: docker build - --no-cache - --network=$(docker network ls | grep github | awk '{print $1}') - -t beryju/passbook-static:${GITHUB_REF##*/} - -f static.Dockerfile . - - name: Push Docker Container to Registry - run: docker push beryju/passbook-static:${GITHUB_REF##*/} diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0c5a9a8c4..90947e819 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -142,3 +142,47 @@ stages: - task: CmdLine@2 inputs: script: bash <(curl -s https://codecov.io/bash) + - stage: Build + jobs: + - job: build-server + pool: + vmImage: 'ubuntu-latest' + steps: + - task: Docker@2 + inputs: + containerRegistry: 'dockerhub' + repository: 'beryju/passbook' + command: 'buildAndPush' + Dockerfile: 'Dockerfile' + tags: '$(Build.SourceBranchName)' + - job: build-gatekeeper + pool: + vmImage: 'ubuntu-latest' + steps: + - task: CmdLine@2 + inputs: + script: cd gatekeeper + - task: Docker@2 + inputs: + containerRegistry: 'dockerhub' + repository: 'beryju/passbook-gatekeeper' + command: 'buildAndPush' + Dockerfile: 'Dockerfile' + tags: '$(Build.SourceBranchName)' + - job: build-gatekeeper + pool: + vmImage: 'ubuntu-latest' + steps: + - task: DockerCompose@0 + displayName: Run services + inputs: + dockerComposeFile: 'scripts/docker-compose.yml' + action: 'Run services' + buildImages: false + - task: Docker@2 + inputs: + containerRegistry: 'dockerhub' + repository: 'beryju/passbook-static' + command: 'buildAndPush' + Dockerfile: 'Dockerfile' + tags: '$(Build.SourceBranchName)' From 40fd1c9c1fa6d38350c0959f249be2752f503bd5 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 28 May 2020 19:45:25 +0200 Subject: [PATCH 05/15] ci: fix duplicate key --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 90947e819..a88f151d9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -169,7 +169,7 @@ stages: command: 'buildAndPush' Dockerfile: 'Dockerfile' tags: '$(Build.SourceBranchName)' - - job: build-gatekeeper + - job: build-static pool: vmImage: 'ubuntu-latest' steps: From 7e52711e3a169cd494be141e3cc07b4327719254 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 28 May 2020 19:46:10 +0200 Subject: [PATCH 06/15] ci: fix names of build jobs --- azure-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a88f151d9..11e661290 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -144,7 +144,7 @@ stages: script: bash <(curl -s https://codecov.io/bash) - stage: Build jobs: - - job: build-server + - job: build_server pool: vmImage: 'ubuntu-latest' steps: @@ -155,7 +155,7 @@ stages: command: 'buildAndPush' Dockerfile: 'Dockerfile' tags: '$(Build.SourceBranchName)' - - job: build-gatekeeper + - job: build_gatekeeper pool: vmImage: 'ubuntu-latest' steps: @@ -169,7 +169,7 @@ stages: command: 'buildAndPush' Dockerfile: 'Dockerfile' tags: '$(Build.SourceBranchName)' - - job: build-static + - job: build_static pool: vmImage: 'ubuntu-latest' steps: From 7e7ea47f3935c22ccc40b15139c2e763cec1e339 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 28 May 2020 21:00:30 +0200 Subject: [PATCH 07/15] ci: fix level of stages on build jobs --- azure-pipelines.yml | 66 ++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 11e661290..dae4867ad 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -147,42 +147,42 @@ stages: - job: build_server pool: vmImage: 'ubuntu-latest' - steps: - - task: Docker@2 - inputs: - containerRegistry: 'dockerhub' - repository: 'beryju/passbook' - command: 'buildAndPush' - Dockerfile: 'Dockerfile' - tags: '$(Build.SourceBranchName)' + steps: + - task: Docker@2 + inputs: + containerRegistry: 'dockerhub' + repository: 'beryju/passbook' + command: 'buildAndPush' + Dockerfile: 'Dockerfile' + tags: '$(Build.SourceBranchName)' - job: build_gatekeeper pool: vmImage: 'ubuntu-latest' - steps: - - task: CmdLine@2 - inputs: - script: cd gatekeeper - - task: Docker@2 - inputs: - containerRegistry: 'dockerhub' - repository: 'beryju/passbook-gatekeeper' - command: 'buildAndPush' - Dockerfile: 'Dockerfile' - tags: '$(Build.SourceBranchName)' + steps: + - task: CmdLine@2 + inputs: + script: cd gatekeeper + - task: Docker@2 + inputs: + containerRegistry: 'dockerhub' + repository: 'beryju/passbook-gatekeeper' + command: 'buildAndPush' + Dockerfile: 'Dockerfile' + tags: '$(Build.SourceBranchName)' - job: build_static pool: vmImage: 'ubuntu-latest' - steps: - - task: DockerCompose@0 - displayName: Run services - inputs: - dockerComposeFile: 'scripts/docker-compose.yml' - action: 'Run services' - buildImages: false - - task: Docker@2 - inputs: - containerRegistry: 'dockerhub' - repository: 'beryju/passbook-static' - command: 'buildAndPush' - Dockerfile: 'Dockerfile' - tags: '$(Build.SourceBranchName)' + steps: + - task: DockerCompose@0 + displayName: Run services + inputs: + dockerComposeFile: 'scripts/docker-compose.yml' + action: 'Run services' + buildImages: false + - task: Docker@2 + inputs: + containerRegistry: 'dockerhub' + repository: 'beryju/passbook-static' + command: 'buildAndPush' + Dockerfile: 'Dockerfile' + tags: '$(Build.SourceBranchName)' From 02f0712934b842f064bc86476242f0609cea6867 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 28 May 2020 21:19:06 +0200 Subject: [PATCH 08/15] ci: fix static being built on wrong docker image --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index dae4867ad..a49cffbcc 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -184,5 +184,5 @@ stages: containerRegistry: 'dockerhub' repository: 'beryju/passbook-static' command: 'buildAndPush' - Dockerfile: 'Dockerfile' + Dockerfile: 'static.Dockerfile' tags: '$(Build.SourceBranchName)' From 2e67b0194b9d096886804f877be107ea43938fae Mon Sep 17 00:00:00 2001 From: Jens L Date: Fri, 29 May 2020 09:15:57 +0200 Subject: [PATCH 09/15] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a49cffbcc..589bcbaeb 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -140,6 +140,7 @@ stages: inputs: script: pipenv run coverage xml - task: CmdLine@2 + inputs: script: bash <(curl -s https://codecov.io/bash) - stage: Build From e02ff7ec300ce2a86074d42f50c411a2e900d446 Mon Sep 17 00:00:00 2001 From: Jens L Date: Fri, 29 May 2020 09:18:17 +0200 Subject: [PATCH 10/15] ci: fix codecov token not being set correctly --- azure-pipelines.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 589bcbaeb..37e37ef79 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -140,7 +140,8 @@ stages: inputs: script: pipenv run coverage xml - task: CmdLine@2 - + env: + CODECOV_TOKEN: $(CODECOV_TOKEN) inputs: script: bash <(curl -s https://codecov.io/bash) - stage: Build From 4d835b18cc925b1429cf58c62e2271115ce29eb8 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 29 May 2020 09:43:00 +0200 Subject: [PATCH 11/15] ci: fix network for static build --- README.md | 2 +- azure-pipelines.yml | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a77266825..bb83b5d40 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # passbook -![](https://img.shields.io/github/workflow/status/beryju/passbook/passbook-ci?style=flat-square) +![](https://img.shields.io/azure-devops/build/beryjuorg/5d94b893-6dea-4f68-a8fe-10f1674fc3a9/1?style=flat-square) ![](https://img.shields.io/docker/pulls/beryju/passbook.svg?style=flat-square) ![](https://img.shields.io/docker/pulls/beryju/passbook-gatekeeper.svg?style=flat-square) ![](https://img.shields.io/docker/pulls/beryju/passbook-static.svg?style=flat-square) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 37e37ef79..4a63bb065 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -181,10 +181,20 @@ stages: dockerComposeFile: 'scripts/docker-compose.yml' action: 'Run services' buildImages: false + - task: CmdLine@2 + inputs: + script: docker network ls - task: Docker@2 inputs: containerRegistry: 'dockerhub' repository: 'beryju/passbook-static' - command: 'buildAndPush' + command: 'build' Dockerfile: 'static.Dockerfile' tags: '$(Build.SourceBranchName)' + arguments: "--network=$(docker network ls | grep github | awk '{print $1}')" + - task: Docker@2 + inputs: + containerRegistry: 'dockerhub' + repository: 'beryju/passbook-static' + command: 'push' + tags: '$(Build.SourceBranchName)' From 1c906b12bebc7516d15691d054c3e97c0551c38c Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 29 May 2020 10:04:23 +0200 Subject: [PATCH 12/15] ci: set static network for static build --- azure-pipelines.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4a63bb065..c773ff6de 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -181,9 +181,6 @@ stages: dockerComposeFile: 'scripts/docker-compose.yml' action: 'Run services' buildImages: false - - task: CmdLine@2 - inputs: - script: docker network ls - task: Docker@2 inputs: containerRegistry: 'dockerhub' @@ -191,7 +188,7 @@ stages: command: 'build' Dockerfile: 'static.Dockerfile' tags: '$(Build.SourceBranchName)' - arguments: "--network=$(docker network ls | grep github | awk '{print $1}')" + arguments: "--network=beryjupassbook_default" - task: Docker@2 inputs: containerRegistry: 'dockerhub' From abea85b6357b36c63a4f3e0637f6f9d977517b89 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 3 Jul 2020 09:39:23 +0200 Subject: [PATCH 13/15] ci: fix incorrect node version for pyright --- azure-pipelines.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a482669c8..e2e8a9cdc 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -78,6 +78,8 @@ stages: vmImage: ubuntu-latest steps: - task: UseNode@1 + inputs: + version: '12.x' - task: UsePythonVersion@0 inputs: versionSpec: '3.8' From ceb0793bc9f5d3b953db521c6a602134f53447e5 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 3 Jul 2020 09:54:25 +0200 Subject: [PATCH 14/15] ci: publish unittest results and coverage --- azure-pipelines.yml | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e2e8a9cdc..e36928298 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -135,28 +135,44 @@ stages: script: | sudo pip install -U wheel pipenv pipenv install --dev - - task: CmdLine@2 + - task: DockerCompose@0 + displayName: Run ChromeDriver inputs: - script: | - cd e2e - docker-compose pull -q chrome - docker-compose up -d chrome + dockerComposeFile: 'e2e/docker-compose.yml' + action: 'Run a specific service' + serviceName: 'chrome' - task: CmdLine@2 + displayName: Build static files for e2e inputs: script: | cd passbook/static/static yarn - task: CmdLine@2 + displayName: Run full test suite inputs: script: pipenv run coverage run ./manage.py test --failfast - task: PublishBuildArtifacts@1 + condition: failed() + displayName: Upload screenshots if selenium tests fail inputs: PathtoPublish: 'selenium_screenshots/' ArtifactName: 'drop' publishLocation: 'Container' - task: CmdLine@2 inputs: - script: pipenv run coverage xml + script: | + pipenv run coverage xml + pipenv run coverage html + - task: PublishCodeCoverageResults@1 + inputs: + codeCoverageTool: Cobertura + summaryFileLocation: 'coverage.xml' + reportDirectory: 'htmlcov' + - task: PublishTestResults@2 + condition: succeededOrFailed() + inputs: + testResultsFiles: 'unittest.xml' + testRunTitle: 'Publish test results for Python $(python.version)' - task: CmdLine@2 env: CODECOV_TOKEN: $(CODECOV_TOKEN) From 0bdfccc1f30a493578ff4aff87c88605e1d4fcae Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 3 Jul 2020 10:17:24 +0200 Subject: [PATCH 15/15] ci: final cleanup --- azure-pipelines.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e36928298..b0107ddbe 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -167,12 +167,11 @@ stages: inputs: codeCoverageTool: Cobertura summaryFileLocation: 'coverage.xml' - reportDirectory: 'htmlcov' - task: PublishTestResults@2 condition: succeededOrFailed() inputs: - testResultsFiles: 'unittest.xml' testRunTitle: 'Publish test results for Python $(python.version)' + testResultsFiles: 'unittest.xml' - task: CmdLine@2 env: CODECOV_TOKEN: $(CODECOV_TOKEN)