Merge pull request 'feature/ci/gitea-macos-runner' (#50) from feature/ci/gitea-macos-runner into develop

Reviewed-on: Loverde-Company-LTDA/Pedi-Foods-Skip#50
This commit is contained in:
2026-09-11 15:40:30 -03:00
3 changed files with 187 additions and 7 deletions

View File

@@ -9,9 +9,6 @@ jobs:
build-and-upload: build-and-upload:
runs-on: macos-build runs-on: macos-build
env:
BUILD_NUMBER: ${{ github.run_number }}
steps: steps:
- name: Checkout repository (workaround - Gitea git-upload-pack bug, see go-gitea/gitea#21819) - name: Checkout repository (workaround - Gitea git-upload-pack bug, see go-gitea/gitea#21819)
run: | run: |
@@ -55,3 +52,78 @@ jobs:
- name: Clean up API key - name: Clean up API key
if: always() if: always()
run: rm -f fastlane/apikey.json run: rm -f fastlane/apikey.json
- name: Email notification
if: always()
env:
SMTP_USER: ${{ secrets.SMTP_USER }}
SMTP_PASS: ${{ secrets.SMTP_PASS }}
NOTIFY_EMAIL_TO: ${{ secrets.NOTIFY_EMAIL_TO }}
run: |
STATUS="${{ job.status }}"
WORKFLOW="${{ github.workflow }}"
JOB="${{ github.job }}"
BRANCH="${{ github.ref_name }}"
COMMIT="${{ github.sha }}"
COMMIT_SHORT="${COMMIT:0:7}"
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
YEAR="$(date +%Y)"
if [ "$STATUS" = "success" ]; then
BADGE_BG="#dcfce7"; BADGE_FG="#166534"; BADGE_LABEL="SUCESSO"; TITLE="Pipeline concluído com sucesso"
else
BADGE_BG="#fee2e2"; BADGE_FG="#991b1b"; BADGE_LABEL="FALHA"; TITLE="Pipeline falhou"
fi
SUBJECT="[PediFoods CI] ${BADGE_LABEL} - ${WORKFLOW}"
HTML_BODY=$(cat <<HTMLEOF
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>${SUBJECT}</title>
</head>
<body style="margin:0;padding:0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;background-color:#f9fafb;color:#1f2937;">
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background-color:#f9fafb;padding:30px 0;">
<tr><td align="center">
<table role="presentation" width="600" cellpadding="0" cellspacing="0" style="max-width:600px;width:100%;background-color:#ffffff;border-radius:8px;overflow:hidden;box-shadow:0 4px 6px -1px rgba(0,0,0,0.1);">
<tr><td style="padding:30px 20px;text-align:center;border-bottom:1px solid #f3f4f6;">
<img src="https://atomenta.com.br/assets/images/logo_2024.png" alt="Atomenta" width="135" style="height:auto;width:135px;display:inline-block;border:0;">
</td></tr>
<tr><td style="padding:40px 30px;">
<div style="text-align:center;"><span style="display:inline-block;padding:4px 14px;border-radius:9999px;font-size:12px;font-weight:700;background-color:${BADGE_BG};color:${BADGE_FG};">${BADGE_LABEL}</span></div>
<h1 style="color:#111827;font-size:22px;font-weight:700;margin:16px 0;text-align:center;">${TITLE}</h1>
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background-color:#f9fafb;border-radius:8px;border:1px solid #e5e7eb;margin:20px 0;">
<tr><td style="padding:12px 20px;border-bottom:1px solid #e5e7eb;font-size:14px;"><strong style="color:#374151;display:inline-block;width:100px;">Workflow:</strong><span style="color:#1f2937;">${WORKFLOW}</span></td></tr>
<tr><td style="padding:12px 20px;border-bottom:1px solid #e5e7eb;font-size:14px;"><strong style="color:#374151;display:inline-block;width:100px;">Job:</strong><span style="color:#1f2937;">${JOB}</span></td></tr>
<tr><td style="padding:12px 20px;border-bottom:1px solid #e5e7eb;font-size:14px;"><strong style="color:#374151;display:inline-block;width:100px;">Branch:</strong><span style="color:#1f2937;">${BRANCH}</span></td></tr>
<tr><td style="padding:12px 20px;font-size:14px;"><strong style="color:#374151;display:inline-block;width:100px;">Commit:</strong><span style="color:#1f2937;">${COMMIT_SHORT}</span></td></tr>
</table>
<div style="text-align:center;margin-top:10px;"><a href="${RUN_URL}" style="display:inline-block;background-color:#111827;color:#ffffff;padding:12px 24px;border-radius:6px;text-decoration:none;font-weight:600;font-size:14px;">Ver execução</a></div>
</td></tr>
<tr><td style="background-color:#f9fafb;padding:24px 20px;text-align:center;font-size:12px;color:#6b7280;border-top:1px solid #e5e7eb;">© ${YEAR} Atomenta</td></tr>
</table>
</td></tr>
</table>
</body>
</html>
HTMLEOF
)
{
printf 'From: Atomenta CI <%s>\r\n' "$SMTP_USER"
printf 'To: %s\r\n' "$NOTIFY_EMAIL_TO"
printf 'Subject: %s\r\n' "$SUBJECT"
printf 'MIME-Version: 1.0\r\n'
printf 'Content-Type: text/html; charset=UTF-8\r\n'
printf '\r\n'
printf '%s\r\n' "$HTML_BODY"
} | curl --silent --show-error \
--url "smtp://mail.loverde.com.br:587" \
--ssl-reqd \
--mail-from "$SMTP_USER" \
--mail-rcpt "$NOTIFY_EMAIL_TO" \
--user "$SMTP_USER:$SMTP_PASS" \
--upload-file - || true

View File

@@ -24,3 +24,78 @@ jobs:
- name: Run tests with coverage - name: Run tests with coverage
run: fastlane tests run: fastlane tests
- name: Email notification
if: always()
env:
SMTP_USER: ${{ secrets.SMTP_USER }}
SMTP_PASS: ${{ secrets.SMTP_PASS }}
NOTIFY_EMAIL_TO: ${{ secrets.NOTIFY_EMAIL_TO }}
run: |
STATUS="${{ job.status }}"
WORKFLOW="${{ github.workflow }}"
JOB="${{ github.job }}"
BRANCH="${{ github.ref_name }}"
COMMIT="${{ github.sha }}"
COMMIT_SHORT="${COMMIT:0:7}"
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
YEAR="$(date +%Y)"
if [ "$STATUS" = "success" ]; then
BADGE_BG="#dcfce7"; BADGE_FG="#166534"; BADGE_LABEL="SUCESSO"; TITLE="Pipeline concluído com sucesso"
else
BADGE_BG="#fee2e2"; BADGE_FG="#991b1b"; BADGE_LABEL="FALHA"; TITLE="Pipeline falhou"
fi
SUBJECT="[PediFoods CI] ${BADGE_LABEL} - ${WORKFLOW}"
HTML_BODY=$(cat <<HTMLEOF
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>${SUBJECT}</title>
</head>
<body style="margin:0;padding:0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;background-color:#f9fafb;color:#1f2937;">
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background-color:#f9fafb;padding:30px 0;">
<tr><td align="center">
<table role="presentation" width="600" cellpadding="0" cellspacing="0" style="max-width:600px;width:100%;background-color:#ffffff;border-radius:8px;overflow:hidden;box-shadow:0 4px 6px -1px rgba(0,0,0,0.1);">
<tr><td style="padding:30px 20px;text-align:center;border-bottom:1px solid #f3f4f6;">
<img src="https://atomenta.com.br/assets/images/logo_2024.png" alt="Atomenta" width="135" style="height:auto;width:135px;display:inline-block;border:0;">
</td></tr>
<tr><td style="padding:40px 30px;">
<div style="text-align:center;"><span style="display:inline-block;padding:4px 14px;border-radius:9999px;font-size:12px;font-weight:700;background-color:${BADGE_BG};color:${BADGE_FG};">${BADGE_LABEL}</span></div>
<h1 style="color:#111827;font-size:22px;font-weight:700;margin:16px 0;text-align:center;">${TITLE}</h1>
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background-color:#f9fafb;border-radius:8px;border:1px solid #e5e7eb;margin:20px 0;">
<tr><td style="padding:12px 20px;border-bottom:1px solid #e5e7eb;font-size:14px;"><strong style="color:#374151;display:inline-block;width:100px;">Workflow:</strong><span style="color:#1f2937;">${WORKFLOW}</span></td></tr>
<tr><td style="padding:12px 20px;border-bottom:1px solid #e5e7eb;font-size:14px;"><strong style="color:#374151;display:inline-block;width:100px;">Job:</strong><span style="color:#1f2937;">${JOB}</span></td></tr>
<tr><td style="padding:12px 20px;border-bottom:1px solid #e5e7eb;font-size:14px;"><strong style="color:#374151;display:inline-block;width:100px;">Branch:</strong><span style="color:#1f2937;">${BRANCH}</span></td></tr>
<tr><td style="padding:12px 20px;font-size:14px;"><strong style="color:#374151;display:inline-block;width:100px;">Commit:</strong><span style="color:#1f2937;">${COMMIT_SHORT}</span></td></tr>
</table>
<div style="text-align:center;margin-top:10px;"><a href="${RUN_URL}" style="display:inline-block;background-color:#111827;color:#ffffff;padding:12px 24px;border-radius:6px;text-decoration:none;font-weight:600;font-size:14px;">Ver execução</a></div>
</td></tr>
<tr><td style="background-color:#f9fafb;padding:24px 20px;text-align:center;font-size:12px;color:#6b7280;border-top:1px solid #e5e7eb;">© ${YEAR} Atomenta</td></tr>
</table>
</td></tr>
</table>
</body>
</html>
HTMLEOF
)
{
printf 'From: Atomenta CI <%s>\r\n' "$SMTP_USER"
printf 'To: %s\r\n' "$NOTIFY_EMAIL_TO"
printf 'Subject: %s\r\n' "$SUBJECT"
printf 'MIME-Version: 1.0\r\n'
printf 'Content-Type: text/html; charset=UTF-8\r\n'
printf '\r\n'
printf '%s\r\n' "$HTML_BODY"
} | curl --silent --show-error \
--url "smtp://mail.loverde.com.br:587" \
--ssl-reqd \
--mail-from "$SMTP_USER" \
--mail-rcpt "$NOTIFY_EMAIL_TO" \
--user "$SMTP_USER:$SMTP_PASS" \
--upload-file - || true

View File

@@ -1,8 +1,32 @@
# This file contains the fastlane.tools configuration for the PediFoods iOS app. # This file contains the fastlane.tools configuration for the PediFoods iOS app.
# You can find the documentation at https://docs.fastlane.tools # You can find the documentation at https://docs.fastlane.tools
require "date"
require "json"
require "fileutils"
default_platform(:ios) default_platform(:ios)
# Build number scheme: "YYYY.MM.DD.0.0.<n>" - <n> increments across
# builds made on the same calendar day, resets to 1 on a new day.
# Needs somewhere to remember "the last <n> used, and for which day",
# and the per-run checkout under .cache/act/<random-hash>/ can't be
# that place - each CI run gets a fresh, throwaway clone, so anything
# written there is gone by the next run. State lives instead at a fixed
# path under this CI user's home directory on the Mac mini runner,
# which is the same machine/user across every run.
def next_build_version
state_path = File.expand_path("~/ci-build-version-state/pedifoods.json")
FileUtils.mkdir_p(File.dirname(state_path))
today = Date.today.strftime("%Y.%m.%d")
state = File.exist?(state_path) ? JSON.parse(File.read(state_path)) : {}
build_number = (state["date"] == today) ? state["build_number"].to_i + 1 : 1
File.write(state_path, JSON.generate({ "date" => today, "build_number" => build_number }))
"#{today}.0.0.#{build_number}"
end
lane :tests do lane :tests do
run_tests( run_tests(
scheme: "PediFoods", scheme: "PediFoods",
@@ -16,10 +40,19 @@ lane :assemble do |options|
# Manual signing (team/identity/profile) for the "PediFoods" target is # Manual signing (team/identity/profile) for the "PediFoods" target is
# baked directly into PediFoods.xcodeproj's own project settings - not # baked directly into PediFoods.xcodeproj's own project settings - not
# overridden here. # overridden here.
# agvtool needs VERSIONING_SYSTEM = apple-generic, which this project doesn't #
# set, so it silently no-ops - pass CURRENT_PROJECT_VERSION directly instead. # CURRENT_PROJECT_VERSION IS overridden here, with next_build_version
xcargs = "-skipPackagePluginValidation -skipMacroValidation" # (see top of file) rather than the project's own committed value.
xcargs += " CURRENT_PROJECT_VERSION=#{ENV['BUILD_NUMBER']}" if ENV["BUILD_NUMBER"] # Earlier versions of this lane either used the committed value as-is
# (fine until you forget to bump it and Apple rejects a duplicate
# build number) or overrode it with the CI job's raw run-number
# counter (BUILD_NUMBER = github.run_number-style, which silently
# uploaded a build as "51" with no relation to the real version at
# all). next_build_version keeps the real date-based scheme and
# bumps only the last component automatically, so every push
# is guaranteed a fresh, correctly-formatted, ever-increasing build
# number with no manual edit needed before each run.
xcargs = "-skipPackagePluginValidation -skipMacroValidation CURRENT_PROJECT_VERSION=#{next_build_version}"
build_app( build_app(
scheme: "PediFoods", scheme: "PediFoods",