Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Description
Description

## Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
- [ ] Refactor (no functional changes)
- [ ] Test update
152 changes: 152 additions & 0 deletions .github/workflows/pr_status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
name: Pull request workflow

on:
pull_request:
branches: [ "develop", "main" ]

jobs:
paths-filter:
name: Verify targets to run tests
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
- name: Check for file changes
uses: dorny/paths-filter@v2
id: filter
with:
filters: |
app:
- 'Projects/App/**'
dependency_injection:
- 'Projects/DependencyInjection/**'
design_system:
- 'Projects/DesignSystem/**'
home:
- 'Projects/Home/**'
detail:
- 'Projects/Detail/**'
- name: Generate matrix
id: matrix
run: |
targets=()
if [ "${{ steps.filter.outputs.app }}" == "true" ]; then
targets+=("App")
fi

if [ "${{ steps.filter.outputs.dependency_injection }}" == "true" ]; then
targets+=("DependencyInjection")
fi

if [ "${{ steps.filter.outputs.design_system }}" == "true" ]; then
targets+=("DesignSystem")
fi

if [ "${{ steps.filter.outputs.home }}" == "true" ]; then
targets+=("Home")
fi

if [ "${{ steps.filter.outputs.detail }}" == "true" ]; then
targets+=("Detail")
fi

if [ ${#targets[@]} -gt 0 ]; then
matrix="{\"target\": [$(printf '"%s",' "${targets[@]}" | sed 's/,$//')]}"
else
matrix='{"target": []}'
fi
echo "matrix=$matrix" >> $GITHUB_OUTPUT

test:
name: Test ${{ matrix.target }}
runs-on: macos-26
needs: paths-filter
if: fromJson(needs.paths-filter.outputs.matrix).target[0] != null
strategy:
matrix: ${{ fromJson(needs.paths-filter.outputs.matrix) }}
permissions:
pull-requests: write
issues: write
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
- name: CI Setup
run: make ci-setup
- name: Install dependencies
run: tuist install
- name: Generate project
run: tuist generate --no-open
- name: Run tests for ${{ matrix.target }}
run: exec fastlane tests target:${{ matrix.target }}
- name: Generate code coverage
run: fastlane tests_coverage target:${{ matrix.target }}
- name: Zip reports
run: zip -r reports-${{ matrix.target }}.zip reports-${{ matrix.target }}/test_output/
- name: Upload test reports
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.target }}
path: reports-${{ matrix.target }}.zip

danger:
name: Danger Code Review
runs-on: ubuntu-latest
needs: [test, paths-filter]
if: |
needs.paths-filter.result == 'success' &&
fromJson(needs.paths-filter.outputs.matrix).target[0] != null &&
needs.test.result == 'success'
permissions:
pull-requests: write
contents: read
statuses: write
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
with:
fetch-depth: 100
- name: Download All Coverage Artifacts
uses: actions/download-artifact@v4
with:
path: all-reports
pattern: test-reports-*
merge-multiple: true
- name: Unzip reports
run: cd all-reports && unzip "*.zip"
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-with: local
- uses: actions/cache@v4
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile') }} # change your gemfile path
restore-keys: |
${{ runner.os }}-gems-
- name: Run Danger
uses: MeilCli/danger-action@v6
with:
plugins_file: 'Gemfile'
install_path: 'vendor/bundle'
danger_file: 'Dangerfile'
danger_id: 'danger-pr'
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

check-project:
name: Check project generation
runs-on: macos-26
needs: paths-filter
if: fromJson(needs.paths-filter.outputs.matrix).target[0] == null
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
- name: CI Setup
run: make ci-setup
- name: Install dependencies
run: tuist install
- name: Check project generation
run: tuist generate --no-open
113 changes: 65 additions & 48 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,62 +1,79 @@
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Xcode ###
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/

## Obj-C/Swift specific
*.hmap
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## App packaging
*.ipa
*.dSYM.zip
*.dSYM
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

## Playgrounds
timeline.xctimeline
playground.xcworkspace
### Xcode Patch ###
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcworkspace/contents.xcworkspacedata
/*.gcno

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
# *.xcodeproj
#
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
# .swiftpm
### Projects ###
*.xcodeproj
*.xcworkspace

.build/
### Tuist derived files ###
graph.dot
Derived/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build/

# fastlane
#
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control
### Tuist managed dependencies ###
Tuist/.build

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output
fastlane/README.md
test_output
derived_data
Gemfile.lock
.bundle
reports-*/
.env
4 changes: 4 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
excluded:
- "**/Tests"
- "**/UITests"
- "**/Project.swift"
5 changes: 5 additions & 0 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
tap "tuist/tuist"

brew "tuist"
brew "swiftlint"
brew "xcbeautify"
40 changes: 40 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require 'rexml/document'

# 1. Basic PR checks
warn("PR is still Work in Progress") if github.pr_title.include?("WIP")

# 2. Report Coverage
coverage_folder = "all-reports"

Dir.glob("#{coverage_folder}/reports-*/test_output/cobertura.xml").each do |xml_file|
target_name = xml_file.match(/reports-(.+?)\//)[1]
doc = REXML::Document.new(File.read(xml_file))
coverage_element = doc.root
overall_rate = coverage_element.attributes["line-rate"].to_f
overall_percentage = (overall_rate * 100).to_i

message("Code coverage for #{target_name}: #{overall_percentage}%")
warn("Code coverage for #{target_name} is below 80%: #{overall_percentage}%") if overall_rate < 0.8

# Build table for files
table = "| File | Coverage |\n|------|----------|\n"
files_added = 0

doc.elements.each("//class") do |cls|
file_name = cls.attributes["filename"]

# --- FILTRO ADICIONADO AQUI ---
# Verifica se o nome do arquivo termina com .swift
next unless file_name.end_with?(".swift")

line_rate = cls.attributes["line-rate"].to_f
file_percentage = (line_rate * 100).to_i
table += "| #{file_name} | #{file_percentage}% |\n"
files_added += 1
end

# Só imprime a tabela se houver arquivos Swift encontrados
if files_added > 0
markdown("### Coverage Details for #{target_name}\n#{table}")
end
end
8 changes: 8 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source "https://rubygems.org"

gem "fastlane", "~> 2.232.0"
gem 'slather', "~> 2.8.5"

group :local do
gem 'danger'
end
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
generate-project:
@sh ./scripts/generate-project.sh

local-setup:
@sh ./scripts/local-setup.sh

ci-setup:
@sh ./scripts/ci-setup.sh
Loading
Loading