Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
985b9b2
Desafio 2
lpampolha Sep 20, 2025
c75eae0
Merge remote-tracking branch 'upstream/main'
lpampolha Oct 2, 2025
ecda900
Desafio-3
lpampolha Oct 3, 2025
115050d
Desafio-3-var
lpampolha Oct 4, 2025
a7a663e
Update README.md
lpampolha Oct 4, 2025
e69ca4b
Merge pull request #2 from lpampolha/teste-desafio
lpampolha Oct 4, 2025
61696c3
Update 02-tests-ci.yml
lpampolha Oct 4, 2025
caa8dce
Update README.md
lpampolha Oct 4, 2025
7f4da26
Update README.md
lpampolha Oct 4, 2025
df2b454
Update README.md
lpampolha Oct 4, 2025
070474d
Merge pull request #3 from lpampolha/teste-desafio
lpampolha Oct 4, 2025
2b60755
Desafio-3-readme
lpampolha Oct 4, 2025
caaed3a
Merge pull request #4 from lpampolha/teste-desafio
lpampolha Oct 4, 2025
d58f76f
Desafio-3-readme
lpampolha Oct 4, 2025
a648a51
Update README.md
lpampolha Oct 4, 2025
bbc0867
Update README.md
lpampolha Oct 4, 2025
e7f1d3d
Merge pull request #6 from lpampolha/teste-desafio
lpampolha Oct 4, 2025
18e1e75
Update 03-build-containers.yml
lpampolha Oct 4, 2025
5eacc1c
Update README.md
lpampolha Oct 4, 2025
37dd9a9
Merge pull request #7 from lpampolha/teste-desafio
lpampolha Oct 4, 2025
dc8953e
Update 03-build-containers.yml
lpampolha Oct 4, 2025
995d394
Update 03-build-containers.yml
lpampolha Oct 4, 2025
04c1d71
Update 03-build-containers.yml
lpampolha Oct 4, 2025
e5a9bdf
Merge pull request #8 from lpampolha/teste-desafio
lpampolha Oct 4, 2025
fec3056
Update 03-build-containers.yml
lpampolha Oct 4, 2025
4342354
Merge pull request #9 from lpampolha/teste-desafio
lpampolha Oct 4, 2025
4db97de
Update 03-build-containers.yml
lpampolha Oct 4, 2025
d78477a
Merge pull request #10 from lpampolha/teste-desafio
lpampolha Oct 4, 2025
612d044
Update 03-build-containers.yml
lpampolha Oct 4, 2025
b5b98be
Merge branch 'lpampolha/desafio-nivel-3' into teste-desafio
lpampolha Oct 4, 2025
5803439
Merge pull request #11 from lpampolha/teste-desafio
lpampolha Oct 4, 2025
ffdc04c
Update 03-build-containers.yml
lpampolha Oct 4, 2025
6d34b51
Merge pull request #12 from lpampolha/teste-desafio
lpampolha Oct 4, 2025
a937db8
Update 03-build-containers.yml
lpampolha Oct 4, 2025
c00fba2
Merge pull request #13 from lpampolha/teste-desafio
lpampolha Oct 4, 2025
4721bd4
Update 03-build-containers.yml
lpampolha Oct 4, 2025
213fa67
Merge pull request #14 from lpampolha/teste-desafio
lpampolha Oct 4, 2025
53dea9d
Desafio-3
lpampolha Oct 4, 2025
14e4b36
Desafio-3
lpampolha Oct 4, 2025
c720e98
Desafio-3-
lpampolha Oct 4, 2025
70006fb
Desafio-3
lpampolha Oct 4, 2025
786968d
Desafio-3
lpampolha Oct 4, 2025
80dde9f
Merge pull request #15 from lpampolha/teste-desafio
lpampolha Oct 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions .github/workflows/02-tests-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
NODE_VERSION: '18'
CHALLENGE_LEVEL: 2
CHALLENGE_NAME: "testes-automatizados"
COVERAGE_MIN: 80 # Cobertura mínima exigida em porcentagem
COVERAGE_MIN: 99 # Cobertura mínima exigida em porcentagem

jobs:
tests-and-coverage:
Expand All @@ -20,18 +20,28 @@ jobs:
- name: "Checkout do código"
uses: actions/checkout@v4

# INSIRA AQUI A LÓGICA PARA RODAR OS TESTES E VERIFICAR A COBERTURA
###
###
###
- name: "Setup Node"
uses: actions/setup-node@v5
with:
node-version: ${{env.NODE_VERSION}}

- name: "Instalar dependências"
run: npm ci
- name: "Executar testes"
run: npm run tests

- name: "Extrair porcentagem de cobertura" # Esse step será validado pelo desafio, não altere o nome. No final, ele deve gerar o output "coverage" com a porcentagem de cobertura.
id: coverage
run: |
COVERAGE=$(npx nyc report --reporter=text-summary | grep -oP 'Statements\s*:\s*\K[0-9\.]+(?=%)' | head -1)
echo "Coverage: $COVERAGE%"
echo "coverage=$COVERAGE" >> $GITHUB_OUTPUT


- name: "Validar se os testes passaram"
if: ${{steps.coverage.outputs.coverage < env.COVERAGE_MIN}}
run: |
echo "Cobertura mínima não atendida: Esperado - ${{ env.COVERAGE_MIN }}%. Atingido: ${{ steps.coverage.outputs.coverage }}%"
exit 1
generate-certificate: # DAQUI PARA BAIXO, NÃO ALTERAR
name: "Desafio Nível 2 - Certificado"
runs-on: ubuntu-latest
Expand Down
42 changes: 40 additions & 2 deletions .github/workflows/03-build-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,49 @@ env:
jobs:
build-scan-and-push:
name: "Build, Lint, Trivy Scan e Push no GHCR"
if: #????
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:
# AQUI VAI O CÓDIGO DO DESAFIO :)
- name: Checkout do código
uses: actions/checkout@v3

- name: Login no GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build da imagem Docker
run: |
docker build -t ghcr.io/${{ github.actor }}/${{ vars.IMAGE_NAME }}:${{ github.sha }} .

- name: Lint do Dockerfile com Hadolint
run: |
hadolint Dockerfile --format tty | tee lint-report.txt
if grep -q "DL3006\|DL3008" lint-report.txt; then
exit 1
fi

- name: Scan de vulnerabilidades com Trivy
uses: aquasecurity/trivy-action@0.28.0
with:
image-ref: ghcr.io/${{ github.actor }}/${{ vars.IMAGE_NAME }}:${{ github.sha }}
format: sarif
output: trivy-report.txt
severity: CRITICAL
exit-code: 1

- name: Publicar imagem no GHCR
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ghcr.io/${{ github.actor }}/${{ vars.IMAGE_NAME }}:${{ github.sha }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

generate-certificate: # DAQUI PARA BAIXO, NÃO ALTERAR
name: "Desafio Nível 3 - Certificado"
Expand Down
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
"author": "LINUXtips",
"license": "MIT",
"dependencies": {
"express": "^4.18.2",
"cors": "^2.8.5",
"helmet": "^7.0.0",
"dotenv": "^16.3.1",
"express": "^4.21.2",
"helmet": "^7.0.0",
"node-fetch": "^3.3.2"
},
"devDependencies": {
"jest": "^29.7.0",
"supertest": "^6.3.4",
"nyc": "^17.1.0"
"nyc": "^17.1.0",
"supertest": "^6.3.4"
},
"engines": {
"node": ">=16.0.0"
Expand Down