Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
26 changes: 19 additions & 7 deletions .github/workflows/02-tests-ci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
name: "Nível 2: Testes Automatizados"
on:
pull_request:
branches: [ main ]
branches:
- main
- desafio-nivel-3

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 +22,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
62 changes: 60 additions & 2 deletions .github/workflows/03-build-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,69 @@ 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 repository
uses: actions/checkout@v3

- name: Lint Dockerfile with Hadolint
uses: hadolint/hadolint-action@v2
with:
dockerfile: Dockerfile
format: tty
output-file: lint-report.txt
no-fail: true

- name: Check for DL3006 or DL3008 violations
run: |
if grep -qE "DL3006|DL3008" lint-report.txt; then
echo "Linting failed due to DL3006 or DL3008." && exit 1;
fi

- name: Upload lint report
uses: actions/upload-artifact@v3
with:
name: lint-report
path: lint-report.txt

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Docker image
id: build-image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: false
tags: ghcr.io/${{ github.repository_owner }}/${{ vars.IMAGE_NAME }}:${{ github.sha }}

- name: Scan Docker image for vulnerabilities with Trivy
id: scan-image
uses: aquasecurity/trivy-action@0.28.0
with:
image-ref: ghcr.io/${{ github.repository_owner }}/${{ vars.IMAGE_NAME }}:${{ github.sha }}
format: table
output: trivy-report.txt

- name: Check for critical vulnerabilities
run: |
if grep -q "CRITICAL" trivy-report.txt; then
echo "Critical vulnerabilities found." && exit 1;
fi
shell: bash

- name: Upload Trivy report
uses: actions/upload-artifact@v4
with:
name: trivy-report
path: trivy-report.txt

generate-certificate: # DAQUI PARA BAIXO, NÃO ALTERAR
name: "Desafio Nível 3 - Certificado"
Expand Down
21 changes: 21 additions & 0 deletions LINUXtips-github-actions-main/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Descomplicando Github Actions - Configuração de Ambiente

# Porta do servidor (padrão: 3000)
PORT=3000

# Ambiente de execução
NODE_ENV=development

# URL base da aplicação (para produção)
# BASE_URL=https://seu-dominio.com

# Configurações de monitoramento (opcional)
# MONITORING_ENABLED=true
# WEBHOOK_URL=https://hooks.slack.com/services/...

# GitHub Token para APIs (opcional - para funcionalidades avançadas)
# GITHUB_TOKEN=ghp_...

# Configurações de deploy (opcional)
# DEPLOY_ENVIRONMENT=staging

41 changes: 41 additions & 0 deletions LINUXtips-github-actions-main/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module.exports = {
env: {
browser: true,
commonjs: true,
es2021: true,
node: true,
jest: true
},
extends: [
'eslint:recommended'
],
parserOptions: {
ecmaVersion: 12
},
rules: {
// Regras básicas de qualidade
'indent': ['error', 2],
'linebreak-style': ['error', 'unix'],
'quotes': ['error', 'single'],
'semi': ['error', 'always'],

// Regras de segurança
'no-eval': 'error',
'no-implied-eval': 'error',
'no-new-func': 'error',
'no-script-url': 'error',

// Regras de boas práticas
'no-unused-vars': 'warn',
'no-console': 'warn',
'prefer-const': 'error',
'no-var': 'error'
},
ignorePatterns: [
'node_modules/',
'coverage/',
'dist/',
'build/'
]
};

Loading