Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adiciona testes no CI #33

Merged
merged 16 commits into from
Nov 22, 2023
99 changes: 99 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: tests

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main", "feature/**", "refactor/**", "fix/**", "hotfix/**", ]

env:
CARGO_TERM_COLOR: always

jobs:
lint:
runs-on: ubuntu-latest
name: Lintagem
steps:
- name: Cancela execuções anteriores
uses: styfle/cancel-workflow-action@0.4.1
with:
access_token: ${{ github.token }}

- name: Faz checkout no Pull Request
uses: actions/checkout@v3

- name: Instala o Nix
run: |
BASE_URL='https://raw.githubusercontent.com/ES-Nix/get-nix/' \
&& SHA256=87fa0f1dbfdd28a1f99b39d5bd4dcc39de97bc64 \
&& NIX_RELEASE_VERSION='2.10.2' \
&& curl -fsSL "${BASE_URL}""$SHA256"/get-nix.sh | sh -s -- ${NIX_RELEASE_VERSION} \
&& . "$HOME"/.nix-profile/etc/profile.d/nix.sh \
&& . ~/."$(basename $SHELL)"rc \
&& export TMPDIR=/tmp \
&& nix flake --version \
&& nix registry pin nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b \
&& curl -fsSL https://raw.githubusercontent.com/ES-Nix/get-nix/"$SHA256"/install_direnv_and_nix_direnv.sh | sh \
&& . ~/."$(basename $SHELL)"rc \
&& direnv --version
echo "$HOME"/.nix-profile/bin >> $GITHUB_PATH

- name: Testa lintagem do código
run: nix develop .# --command sh -c 'cd brado && cargo fmt --verbose'

tests:
runs-on: ubuntu-latest
needs: lint
name: Testes
steps:
- name: Faz checkout no Pull Request
uses: actions/checkout@v3

- name: Instala o Nix
run: |
BASE_URL='https://raw.githubusercontent.com/ES-Nix/get-nix/' \
&& SHA256=87fa0f1dbfdd28a1f99b39d5bd4dcc39de97bc64 \
&& NIX_RELEASE_VERSION='2.10.2' \
&& curl -fsSL "${BASE_URL}""$SHA256"/get-nix.sh | sh -s -- ${NIX_RELEASE_VERSION} \
&& . "$HOME"/.nix-profile/etc/profile.d/nix.sh \
&& . ~/."$(basename $SHELL)"rc \
&& export TMPDIR=/tmp \
&& nix flake --version \
&& nix registry pin nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b \
&& curl -fsSL https://raw.githubusercontent.com/ES-Nix/get-nix/"$SHA256"/install_direnv_and_nix_direnv.sh | sh \
&& . ~/."$(basename $SHELL)"rc \
&& direnv --version
echo "$HOME"/.nix-profile/bin >> $GITHUB_PATH

- name: Build
run: nix develop .# --command sh -c 'cd brado && cargo build --verbose'

- name: Run tests
run: nix develop .# --command sh -c 'cd brado && cargo test --verbose'

clippy:
runs-on: ubuntu-latest
needs: tests
name: Clippy
steps:
- name: Faz checkout no Pull Request
uses: actions/checkout@v3

- name: Instala o Nix
run: |
BASE_URL='https://raw.githubusercontent.com/ES-Nix/get-nix/' \
&& SHA256=87fa0f1dbfdd28a1f99b39d5bd4dcc39de97bc64 \
&& NIX_RELEASE_VERSION='2.10.2' \
&& curl -fsSL "${BASE_URL}""$SHA256"/get-nix.sh | sh -s -- ${NIX_RELEASE_VERSION} \
&& . "$HOME"/.nix-profile/etc/profile.d/nix.sh \
&& . ~/."$(basename $SHELL)"rc \
&& export TMPDIR=/tmp \
&& nix flake --version \
&& nix registry pin nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b \
&& curl -fsSL https://raw.githubusercontent.com/ES-Nix/get-nix/"$SHA256"/install_direnv_and_nix_direnv.sh | sh \
&& . ~/."$(basename $SHELL)"rc \
&& direnv --version
echo "$HOME"/.nix-profile/bin >> $GITHUB_PATH

- name: Verifica qualidade do código
run: nix develop .# --command sh -c 'cd brado && cargo clippy --verbose'
Loading