-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkflow-testes-automatizados-api-serve-rest-postman-newman.yml
More file actions
72 lines (58 loc) · 3.2 KB
/
Copy pathworkflow-testes-automatizados-api-serve-rest-postman-newman.yml
File metadata and controls
72 lines (58 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Pipeline Testes Automatizados API ServeRest Postman Newman
# executa o workflow toda vez que for realizado um push ou pull-request na branch principal (main) no repositório
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
# permite também executar esse workflow manualmente na aba "Actions" do GitHub
workflow_dispatch:
jobs:
postman-newman-api-serve-rest:
# agente de execução/runner
runs-on: ubuntu-latest
permissions:
contents: write
pages: write
id-token: write
# envionment com "name: github-pages" e "url: https://andressakarla.github.io/testes-automatizados-api-serve-rest_postman/postman-api-serve-rest-report-htmlextra-newman.html" para deploy/publicar no github pages, configurado automaticamente e aplicado apenas na branch principal (main)
environment: ${{ github.ref == 'refs/heads/main' && 'github-pages' || '' }}
steps:
- name: Passo 1 - Obter cópia do código-fonte do repositório
uses: actions/checkout@v4
- name: Passo 2 - Verificar versões do Node e Newman
run: |
node --version
newman --version
- name: Passo 3 - Instalar newman-reporter-htmlextra globalmente
run: sudo npm install -g newman-reporter-htmlextra
- name: Passo 4 - Executar com Newman testes automatizados de API REST da collection e environment do Postman em um ambiente de produção e Gerar os resultados dos testes
run: newman run ./api-serve-rest_collection.json -e ./api-serve-rest_prod-environment.json --delay-request 2 --reporters cli,htmlextra,junit --reporter-htmlextra-export ./reports/postman-api-serve-rest-report-htmlextra-newman.html --reporter-junit-export ./reports/postman-api-serve-rest-report-junit-xml-newman.xml
- name: Passo 5 - Armazenar os resultados dos testes em reports html e xml
# expressão condicional para que sempre seja executado independentemente dos resultados dos steps anteriores
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: postman-reports-html-junit-xml-newman
path: ./reports
# armazena por 30 dias
retention-days: 30
- name: Passo 6 - Configurar pages apenas na branch principal (main)
if: github.ref == 'refs/heads/main'
uses: actions/configure-pages@v4
- name: Passo 7 - Baixar report html armazenado no "Passo 5 - Armazenar os resultados dos testes em reports html e xml" apenas na branch principal (main)
if: github.ref == 'refs/heads/main'
uses: actions/download-artifact@v4
with:
name: postman-reports-html-junit-xml-newman
path: ./reports
- name: Passo 8 - Armazenar pages apenas na branch principal (main)
if: github.ref == 'refs/heads/main'
uses: actions/upload-pages-artifact@v3
with:
path: ./reports
retention-days: 30
- name: Passo 9 - Deploy/Publicar no Github Pages na "url" configurada automaticamente em "postman-newman-api-serve-rest > environment" apenas na branch principal (main)
if: github.ref == 'refs/heads/main'
id: deployment
uses: actions/deploy-pages@v4