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
89 changes: 89 additions & 0 deletions .github/workflows/apple-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Apple Tests

on:
workflow_call:
inputs:
name:
required: true
type: string
xcode-version:
default: '16.4'
required: false
type: string
platform:
default: 'macOS-15'
required: false
type: string
package-name:
required: true
type: string
destination:
required: true
type: string
coverage-enabled:
default: false
required: false
type: boolean

jobs:
apple-tests:
name: "Testing on ${{ inputs.name }}"
runs-on: ${{ inputs.platform }}
steps:
- name: ⬇️ Get Sources
uses: actions/checkout@v5.0.0

- name: 🍺 Homebrew Dependencies
run: |
brew install xcbeautify

- name: ☑️ Xcode Select
run: sudo xcode-select -switch /Applications/Xcode_${{ inputs.xcode-version }}.app

- name: ⚒️ Build Package
env:
NSUnbufferedIO: YES
run: |
set -o pipefail && xcodebuild build-for-testing \
-scheme "${{ inputs.package-name }}" \
-destination "${{ inputs.destination }}" \
-derivedDataPath .xcbuild 2>&1 | xcbeautify --quiet --renderer github-actions

- name: 🧪 Run Tests with Coverage
env:
NSUnbufferedIO: YES
run: |
set -o pipefail && xcodebuild test-without-building \
-scheme "${{ inputs.package-name }}" \
-destination "${{ inputs.destination }}" \
-enableCodeCoverage YES \
-derivedDataPath .xcbuild 2>&1 | xcbeautify --renderer github-actions

- name: 🔍 Debug - List coverage files
if: inputs.coverage-enabled
run: |
echo "=== Looking for coverage files ==="
find .xcbuild -name "*.profdata" -o -name "*.xctest" 2>/dev/null || echo "No files found"
echo "=== Directory structure ==="
find .xcbuild -type d -name "*Coverage*" -o -name "*DerivedData*" 2>/dev/null || echo "No special directories"

- name: 🔀 Move Coverage Files
if: inputs.coverage-enabled
run: |
mkdir -p coverage-artifacts

# Copiar todos os arquivos .profdata
find .xcbuild -name "*.profdata" -exec cp {} coverage-artifacts/ \; 2>/dev/null || true

# Copiar todos os arquivos .xctest (exceto os dentro de .dSYM)
find .xcbuild -name "*.xctest" -not -path "*/.dSYM/*" -exec cp -r {} coverage-artifacts/ \; 2>/dev/null || true

echo "=== Files moved to coverage-artifacts ==="
ls -la coverage-artifacts/

- name: 📤 Upload Coverage Data
if: inputs.coverage-enabled
uses: actions/upload-artifact@v4.6.2
with:
name: ${{ inputs.name }}
path: coverage-artifacts/
46 changes: 0 additions & 46 deletions .github/workflows/code-coverage.yml

This file was deleted.

102 changes: 102 additions & 0 deletions .github/workflows/coverage-upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Coverage Upload

on:
workflow_call:
inputs:
xcode-version:
default: '16.4'
required: false
type: string
platform:
default: 'macOS-15'
required: false
type: string

jobs:
coverage-upload:
runs-on: ${{ inputs.platform }}
steps:
- name: ⬇️ Get Sources
uses: actions/checkout@v5.0.0

- name: 📥 Download All Artifacts
uses: actions/download-artifact@v5.0.0
with:
path: artifacts

- name: 📁 List Downloaded Artifacts
run: |
echo "Artifacts downloaded:"
ls -la artifacts/
echo "Subdirectories:"
find artifacts -type d -mindepth 1 -maxdepth 1

- name: ☑️ Xcode Select
run: sudo xcode-select -switch /Applications/Xcode_${{ inputs.xcode-version }}.app

- name: 📁 Process Coverage for Each Destination
run: |
# Iterar por cada subpasta de artefato
for artifact_dir in artifacts/*/; do
if [ -d "$artifact_dir" ]; then
echo "=== Processing: $artifact_dir ==="
(
cd "$artifact_dir"

# Extrair o nome do diretório (remove "artifacts/" e "/")
ARTIFACT_DIR_NAME=$(basename "$artifact_dir")

# Encontrar todos os arquivos .profdata
PROFDATA_FILES=$(find . -name "*.profdata" | head -n 1)
PROFDATA_FILE="$PROFDATA_FILES"

if [ -z "$PROFDATA_FILE" ]; then
echo "Nenhum arquivo .profdata encontrado em $artifact_dir"
exit 1
fi

# Encontrar todos os bundles .xctest
find . -name "*.xctest" -type d | while read -r xctest_bundle; do
if [ -n "$xctest_bundle" ]; then
# Extrair o nome base do bundle (sem .xctest)
BUNDLE_NAME=$(basename "$xctest_bundle" .xctest)

# Procurar o executável usando glob pattern (funciona em todas as plataformas)
EXECUTABLE_PATH=$(find "$xctest_bundle" -name "$BUNDLE_NAME" -type f -not -path "*/.dSYM/*" | head -n 1)

# Verificar se o executável existe
if [ -n "$EXECUTABLE_PATH" ] && [ -f "$EXECUTABLE_PATH" ]; then
echo "Processando cobertura para: $BUNDLE_NAME"
echo "Executável encontrado em: $EXECUTABLE_PATH"

# Nome do arquivo de saída usando MD5 do artifact directory
OUTPUT_FILE="${{ github.workspace }}/${ARTIFACT_DIR_NAME}.lcov"

# Gerar relatório de cobertura
xcrun llvm-cov export "$EXECUTABLE_PATH" \
-format="lcov" \
-instr-profile="$PROFDATA_FILE" \
-ignore-filename-regex=".build|Tests" > "$OUTPUT_FILE"

echo "Gerado: $OUTPUT_FILE"
else
echo "Executável não encontrado para: $BUNDLE_NAME"
echo "Buscado em: $xctest_bundle"
fi
fi
done
)
fi
done

- name: 📋 List Generated LCOV Files
run: |
echo "LCOV files generated:"
ls -la *.lcov

- name: 📦 Upload to Codecov
uses: codecov/codecov-action@v5.5.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: "*.lcov"
verbose: true
29 changes: 0 additions & 29 deletions .github/workflows/swift.yml

This file was deleted.

90 changes: 90 additions & 0 deletions .github/workflows/third-party-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Third Party Tests

on:
workflow_call:
inputs:
name:
required: true
type: string
swift-version:
default: '6.1'
required: false
type: string
platform:
required: true
type: string
coverage-enabled:
default: false
required: false
type: boolean

jobs:
third-party-tests:
name: "Testing on ${{ inputs.name }}"
runs-on: ${{ inputs.platform }}
steps:
- name: ☑️ Swift Select
uses: SwiftyLab/setup-swift@v1.11.0
with:
swift-version: ${{ inputs.swift-version }}

- name: ⬇️ Get Sources
uses: actions/checkout@v5.0.0

- name: ⚒️ Test Package
run: swift test --enable-code-coverage

- name: 🔍 Debug - List coverage files (Unix)
if: inputs.coverage-enabled && (runner.os == 'Linux' || runner.os == 'macOS')
run: |
echo "=== Looking for coverage files ==="
find .build -name "*.profdata" -o -name "*.xctest" 2>/dev/null || echo "No files found"

- name: 🔍 Debug - List coverage files (Windows)
if: inputs.coverage-enabled && runner.os == 'Windows'
shell: pwsh
run: |
Write-Host "=== Looking for coverage files ==="
Get-ChildItem -Path .build -Recurse -Include "*.profdata", "*.xctest" -ErrorAction SilentlyContinue

- name: 🔀 Move Coverage Files (Unix)
if: inputs.coverage-enabled && (runner.os == 'Linux' || runner.os == 'macOS')
run: |
mkdir -p coverage-artifacts

# Copiar todos os arquivos .profdata
find .build -name "*.profdata" -exec cp {} coverage-artifacts/ \; 2>/dev/null || true

# Copiar todos os arquivos .xctest (exceto os dentro de .dSYM)
find .build -name "*.xctest" -not -path "*/.dSYM/*" -exec cp -r {} coverage-artifacts/ \; 2>/dev/null || true

echo "=== Files moved to coverage-artifacts ==="
ls -la coverage-artifacts/

- name: 🔀 Move Coverage Files (Windows)
if: inputs.coverage-enabled && runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Path "coverage-artifacts" -Force

# Copiar todos os arquivos .profdata
Get-ChildItem -Path .build -Recurse -Filter "*.profdata" | ForEach-Object {
Copy-Item $_.FullName -Destination "coverage-artifacts" -Force
}

# Copiar todos os arquivos .xctest (exceto os dentro de .dSYM)
Get-ChildItem -Path .build -Recurse -Directory -Filter "*.xctest" | Where-Object {
$_.FullName -notlike "*\.dSYM\*"
} | ForEach-Object {
Copy-Item $_.FullName -Destination "coverage-artifacts" -Recurse -Force
}

Write-Host "=== Files moved to coverage-artifacts ==="
Get-ChildItem -Path "coverage-artifacts"

- name: 📤 Upload Artifacts
if: inputs.coverage-enabled
uses: actions/upload-artifact@v4.6.2
with:
name: ${{ inputs.name }}
path: coverage-artifacts/