Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from filipedeschamps/actions
tests: adiciona suite de testes com Jest e Github Actions
- Loading branch information
Showing
7 changed files
with
4,345 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Testes E2E | ||
|
||
on: [deployment_status] | ||
|
||
jobs: | ||
mark-commit-status-pending: | ||
name: Marcar "status" do commit como "pending" | ||
if: github.event.deployment_status.state == 'pending' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Fazer request contra API do Github com status "pending" | ||
run: | | ||
curl -L -X POST \ | ||
--url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \ | ||
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ | ||
--header 'content-type: application/json' \ | ||
--data '{ | ||
"state": "pending", | ||
"context": "e2e-tests", | ||
"description": "Aguardando a Preview URL da Zeit" | ||
}' | ||
e2e-tests: | ||
name: Rodar testes E2E contra a Preview URL da Zeit | ||
if: github.event.deployment_status.state == 'success' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Atualizar o status "pending" com o "Workflow URL" | ||
run: | | ||
GITHUB_WORKFLOW_URL=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID | ||
curl -L -X POST \ | ||
--url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \ | ||
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ | ||
--header 'content-type: application/json' \ | ||
--data '{ | ||
"state": "pending", | ||
"context": "e2e-tests", | ||
"description": "Realizando testes E2E contra a Preview URL", | ||
"target_url": "'${GITHUB_WORKFLOW_URL}'" | ||
}' | ||
- name: Puxar o código do commit | ||
uses: actions/checkout@v2 | ||
|
||
- name: Instalar o Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: '12.x' | ||
|
||
- name: Instalar as dependências do npm | ||
run: npm install | ||
|
||
- name: Rodar testes utilizando a Preview URL da Zeit | ||
run: npm test | ||
env: | ||
NODE_ENV: 'ci' | ||
PREVIEW_URL: ${{ github.event.deployment_status.target_url }} | ||
|
||
- name: Fazer request contra API do Github status final | ||
if: always() | ||
env: | ||
JOB_CONTEXT: ${{ toJson(job) }} | ||
run: | | ||
GITHUB_WORKFLOW_URL=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID | ||
JOB_STATUS=$(echo ${JOB_CONTEXT} | jq --raw-output '.status | ascii_downcase') | ||
curl -L -X POST \ | ||
--url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \ | ||
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ | ||
--header 'content-type: application/json' \ | ||
--data '{ | ||
"state": "'${JOB_STATUS}'", | ||
"context": "e2e-tests", | ||
"description": "Finalizados os testes E2E contra a Preview URL.", | ||
"target_url": "'${GITHUB_WORKFLOW_URL}'" | ||
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
testTimeout: 30000 | ||
} |
Oops, something went wrong.
050bcd6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to following URLs: