Skip to content

Commit

Permalink
IOS-10797 Change Mistica workflows to use the reusable workflows and …
Browse files Browse the repository at this point in the history
…upload builds to Firebase
  • Loading branch information
pbartolome committed Nov 27, 2024
1 parent 5e191c6 commit 9d756a4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 176 deletions.
77 changes: 22 additions & 55 deletions .github/workflows/build-mistica-catalog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,29 @@ on:
release:
types: [published]
workflow_dispatch:
inputs:
app-center-project:
description: 'App Center app name'
type: choice
options:
- "Internal Enterprise (Mistica-iOS)"
- "Alpha (Mistica-SwiftUI-iOS)"
required: true
inputs:
ref:
required: false
type: string

jobs:
deploy-mistica-catalog:
name: Build enterprise
runs-on: self-hosted-novum-mac
steps:
- name: Set configuration variables
shell: bash
run: |
echo "::group::Setting variables..."
if [ "${{ github.event.inputs.app-center-project }}" = "Internal Enterprise (Mistica-iOS)" ]; then
echo 'APP_CENTER_PROJECT=Mistica-iOS' >> $GITHUB_OUTPUT
elif [ "${{ github.event.inputs.app-center-project }}" = "Alpha (Mistica-SwiftUI-iOS)" ]; then
echo 'APP_CENTER_PROJECT=Mistica-SwiftUI-iOS' >> $GITHUB_OUTPUT
else
# Default value for automatic triggers like `release, `push`, ...
echo 'APP_CENTER_PROJECT=Mistica-iOS' >> $GITHUB_OUTPUT
fi
echo "::endgroup::"
id: variables

- name: Checkout
uses: actions/[email protected]

- name: Checkout Telefonica/github-actions repo
uses: actions/[email protected]
with:
repository: Telefonica/github-actions
token: "${{ secrets.NOVUM_PRIVATE_REPOS }}"
path: .github/actions

- name: Provision Novum Mac for MisticaApp
uses: ./.github/actions/novum/mac-provisioning
with:
setup-ruby: false
brand-variant: MisticaApp
provisioning-profiles: ${{ secrets.MISTICA_CATALOG_ENTERPRISE_PROV_PROFILES }}
certificate-password: ${{ secrets.MISTICA_CATALOG_ENTERPRISE_CERT_PWD }}
apple-system-certs: ${{ secrets.APPLE_CERTS }}

- name: Export
run: make export

- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: 18.13.0

- name: Upload ipa to AppCenter
run: npx -p appcenter-cli appcenter distribute release -a Tuenti-Organization/${{ steps.variables.outputs.APP_CENTER_PROJECT }} -f ./build/ios.ipa -g Public --token ${{ secrets.APPCENTER_API_TOKEN }}

uses: Telefonica/ios-github-workflows/.github/workflows/build-and-export-ipa.yml@main
with:
ref: ${{ inputs.ref || github.ref }}
project-name: "Mistica"
project-path: "MisticaCatalog/MisticaCatalog.xcodeproj"
scheme: "MisticaCatalog"
configuration: "release"
xcode-build-destination: "generic/platform=iOS"
export-destination: "firebase"
export-options: "enterprise.plist"
firebase-app-id: "1:566193653712:ios:07224eb13f3e735f515bd5"
secrets:
CERTIFICATE_BASE64: ${{ secrets.MISTICA_ENTERPRISE_CERTIFICATE }}
CERTIFICATE_PASSWORD: ${{ secrets.MISTICA_ENTERPRISE_P12_PWD }}
APPLE_ENTERPRISE_API_KEY_ID: ${{ secrets.APPLE_ENTERPRISE_API_KEY_ID }}
APPLE_ENTERPRISE_API_PRIVATE_KEY: ${{ secrets.APPLE_ENTERPRISE_API_PRIVATE_KEY }}
APPLE_ENTERPRISE_API_ISSUER_ID: ${{ secrets.APPLE_ENTERPRISE_API_ISSUER_ID }}
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.MISTICA_GOOGLE_APPLICATION_CREDENTIALS }}
44 changes: 8 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,11 @@ on:
type: string

jobs:
test:
name: Run Tests
runs-on: self-hosted-novum-mac

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || '' }}

- name: Build and Test
run: make test

- name: Extract Screenshot diff from failed Tests
if: always()
run: make extract_tests_attachments

- name: Checkout Telefonica/github-actions repo
uses: actions/checkout@v4
if: always()
with:
repository: Telefonica/github-actions
token: "${{ secrets.NOVUM_PRIVATE_REPOS }}"
path: .github/actions

- name: Check Tests result
uses: ./.github/actions/mistica/upload-failed-screenshots
if: always()
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
azure-account-name: ${{ secrets.AZURE_ACCOUNT_NAME }}
azure-account-key: ${{ secrets.AZURE_ACCOUNT_KEY }}
glob: 'tmp/test_output/diff_output/**/difference*.png'
test-suite-and-test-name-regex: '(?<=diff_output\/)(.*)(?=\/difference)'
test-suite-and-test-name-separator: '/'
ci-container-name: 'mistica-ios-ci-container'
mistica-tests:
name: Tests
uses: Telefonica/ios-github-workflows/.github/workflows/test.yml@main
with:
ref: ${{ inputs.ref || github.ref }}
scheme: "Mistica"
xcode-build-destination: "platform=iOS Simulator,name=iPhone 16,OS=18.0"
upload-failed-screenshots: true
1 change: 1 addition & 0 deletions .xcode-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16.0
87 changes: 2 additions & 85 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,60 +1,16 @@
.PHONY: help setup format test simulator archive export clean skin

# Simulator
OS_VERSION := 18.0
DEVICE_NAME := iPhone 16
SIMULATOR_NAME := $(DEVICE_NAME) ($(OS_VERSION))
GET_INSTALLED_SIMULATOR_NAME := $(shell xcrun simctl list | grep -o "$(SIMULATOR_NAME)" | head -1)
DESTINATION := platform=iOS Simulator,OS=$(OS_VERSION),name=$(DEVICE_NAME)

# Paths
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
TMP_ROOT_PATH := $(ROOT_DIR)/tmp
TEST_OUTPUT_PATH := $(TMP_ROOT_PATH)/test_output
SCREENSHOT_DIFFS_OUTPUT_PATH = $(TEST_OUTPUT_PATH)/diff_output
XCRESULT_FILE_PATH := $(TEST_OUTPUT_PATH)/$(SCHEMA).xcresult
.PHONY: help setup format skin

# Export config
SCHEMA := MisticaCatalog
TEST_SCHEMA := Mistica
PROJECT_PATH := MisticaCatalog/MisticaCatalog.xcodeproj
BUILD_PATH := $(ROOT_DIR)/build
EXPORTED_OPTIONS_PATH := $(ROOT_DIR)/enterprise.plist
ARCHIVE_PATH := $(TMP_ROOT_PATH)/ios.xcarchive
XCODEBUILD := set -o pipefail && xcodebuild
MISTICA_DESIGN_TOKENS_PATH := /tokens
MISTICA_DESIGN_URL := https://raw.githubusercontent.com/Telefonica/mistica-design/$(ref)/tokens

# Xcode
ifneq ($(origin GITHUB_ACTION),undefined)
export DEVELOPER_DIR=/Applications/Xcode-16.0.app/Contents/Developer
endif

# Targets
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " setup to set up dependencies"
@echo " format to execute swiftformat in Sources directory"
@echo " test to build and test the main target"
@echo " simulator to install the simulator for testing"
@echo " export to export the archived project as an .ipa"
@echo " clean to remove all temporal files"
@echo " skin to regenerate and format tokens from mistica design"

trace:
@echo "Current xcodebuild configuration"
@xcodebuild -version
@echo "Available schemas"
@xcodebuild -list -json
@echo "Available devices"
@xcrun xctrace list devices
@xcrun --sdk iphonesimulator --show-sdk-path

setup: trace
@echo "Installing dependencies..."
@brew ls chargepoint/xcparse/xcparse --versions || brew install chargepoint/xcparse/xcparse
@brew ls xcbeautify --versions || brew install xcbeautify

skinGeneratorSetup:
@echo "Installing tokens generator dependencies"
@brew ls node --versions || brew install node
Expand All @@ -63,47 +19,8 @@ skinGeneratorSetup:
format:
Scripts/swiftformat .

test: clean setup simulator
@echo "Testing with simulator $(SIMULATOR_NAME)"
$(XCODEBUILD) build-for-testing -scheme $(TEST_SCHEMA) -destination "$(DESTINATION)" | xcbeautify
$(XCODEBUILD) test-without-building -scheme $(TEST_SCHEMA) -resultBundlePath $(XCRESULT_FILE_PATH) -destination "$(DESTINATION)" | xcbeautify

extract_tests_attachments:
@xcparse attachments $(XCRESULT_FILE_PATH) $(SCREENSHOT_DIFFS_OUTPUT_PATH) --uti public.plain-text public.image --test

simulator:
@echo "Installing simulator $(SIMULATOR_NAME)"
ifneq ($(GET_INSTALLED_SIMULATOR_NAME), $(SIMULATOR_NAME))
@echo "Instaling simulator $(SIMULATOR_NAME)"
@xcrun simctl create "$(SIMULATOR_NAME)" "$(DEVICE_NAME)" iOS$(OS_VERSION)
else
@echo "Simulator $(SIMULATOR_NAME) already exists"
endif

clean:
@rm -rf "$(TMP_ROOT_PATH)"

export: clean setup
@echo "Building $(SCHEMA)"

@echo "Removing previous build..."
@rm -rf "$(BUILD_PATH)"

@echo "Archiving..."
$(XCODEBUILD) -project "$(PROJECT_PATH)" -scheme $(SCHEMA) clean archive -configuration release -sdk iphoneos -archivePath "$(ARCHIVE_PATH)" -destination generic/platform=iOS | xcbeautify

@echo "Exporting..."
$(XCODEBUILD) -exportArchive -archivePath "$(ARCHIVE_PATH)" -exportPath "$(TMP_ROOT_PATH)" -exportOptionsPlist "$(EXPORTED_OPTIONS_PATH)" | xcbeautify

@echo "Moving artifacts to $(BUILD_PATH)"
@mkdir -p "$(BUILD_PATH)"
@find "$(TMP_ROOT_PATH)" -name "*.ipa" | xargs -I '{}' mv {} "$(BUILD_PATH)/ios.ipa"
@find "$(TMP_ROOT_PATH)" -name "*.dSYM" | xargs -I '{}' mv {} "$(BUILD_PATH)/ios.dSYM"

@rm -rf "$(TMP_ROOT_PATH)"

tokensGeneration:
@echo "Executing tokens generation tool..."
cd scripts/mistica-skin-generator && npm run generate

skin: tokensGeneration format
skin: tokensGeneration format

0 comments on commit 9d756a4

Please sign in to comment.