Skip to content

Commit

Permalink
Architecture + events refactor (#22)
Browse files Browse the repository at this point in the history
* Split up logger helpers, added tests

* Deduplicate notification center event handlers

* fileId rename

* Refactor event sending apis

* Added unit tests for push token registration

* Expose ParraFeedback singleton

* Make Parra shared instance publically accessible

* Refactor config passing to init to be list of options

* Refactor state management to be per Parra instance

* more http header helpers

* Expanding mock capabilities of network manager

* Fixed incorrectly named schemes

* More mock+test data refactor

* Rewrote network mocks/tests

* refactor core parra auth tests

* Consistently use sleep ms helper

* re-implement push token tests

* Refactor remaining tests

* Date.now helper

* Fixed access specifiers

* Better logging around filesystem errors

* whoops

* Maybe fix file reading error

* Explore http metrics collection+reorg

* Publicly expose static Parra methods

* whoops

* Removed obsolete data task mock

* Started improving sync tests

* Use TimeInterval for sleeping tasks

* Fixes and coverage improvements for sync manager tests

* Implemented more device events

* Lazy load feedback module

* formatting

* Added UI test bundle

* WIP logger/session manager overhaul

* well, at least it builds

* measurement -> timers

* Support enabling and disabling logger instances

* Fixed project structure

* Log multiple/support caching pre-init logs and deferring processing

* printDelimiter option

* Still WIP logger and sessions refactor

* changing some thread info types

* Fixed dict convertible naming

* Accepting defeat on formatting dictionaries this way

* Support passing extra data with errors

* Fixed name of session event key

* fix time measurement in logs

* Fix errors when logging errors

* Properly pass down json coding dependencies

* Added helper for create missing files

* Added file handle type enum for session storage

* Improve file system helper safety

* Experimenting with os_log

* Basic support for new session storage with file handles

* Support for debugging events to sessions and console at the same time

* Starting to connect session reader for uploading existing sessions

* more withSync overloads for async/throwing

* Reading and uploading sessions working again!

* Abstraction around multiple session generator types

* DI for shared FileManager instance

* Generator to produce sessions without events

* Improve post-sync cleanup

* Cleanup after sync working properly

* Implemented hasCompletedSessions check

* Fix deleting old sessions

* Audit for consistent completion handler invocation

* Large refactor of how context is tracked

* Removing autoclosures from extra fields

* more

* mm

* Update app id

* Track response data in networking errors

* Set proper defaults for env vars

* Auto open app container in Finder

* Storage path improvements

* Helper for removing sensitive information from URLs

* Fix infinite sync loop for new log events

* better default log format

* Fix build errors in tests

* Inlining things and starting sanitizers

* Compilation error in tests

* Fixed race condition for logger before logger init

* Rewrite overly dangerous backtrace access

* Ability to recover filesystem state after sync errors

* access modifier audit

* Fix errors clearing out failed session uploads

* Fix warnings, update project settings for Xcode 15

* Xcode 15

* Fixed scopes

* Fixed many things

* more test fixes

* init circle

* gen2

* m1

* hmm

* versions

* fix config

* demo

* Introduced separate test host app

* xcode 15.1.0

*  Silicon

* gems

* working_directory

* ls

* add brew install script

* bun

* install rosetta

* Removing fastlane

* formatting

* bun binary lockfile

* ignore buildlog

* remove package.json

* commander

* moving tests around

* build for testing working

* clean up vars

* ignore artifacts dir

* code signing

* fixed dir

* typo

* more path fixes

* -allowProvisioningUpdates

* comment and grouping

* first attempt at running tests

* -allowProvisioningDeviceRegistration

* no code sign

* manual signing

* platform

* trying disabling catalyst

* destination

* preboot sim

* whoops

* wait for boot before building

* back to medium

* only run on main for now

* Build

* zip artifacts

* speed

* Bump bundler to 2.4.22

* script to disable physical hardware

* fixed permissions

* vars

* Remove old GH actions CI and updated documented deploy target

* maybe

* passing vars between jobs

* name is restricted

* escape

* param brackets

* workspace dir

* script dir

* hmm

* root

* hmm

* mm

* hmm

* idk

* shallow

* bump

* come on now

* async

* background

* no parallel

* race

* do we even need to?

* cool

* yay

* hmm

* cleanup

* WIP moving CLI

* Most of CLI implementent

* sigh

* bun

* Install bun first

* mhm

* using the orb

* more quiet

* fixed cli/bin not checked in

* disable keyboard can have stderr

* Fix log levels and common args

* whatever

* Update code and utilities

* hm

* xcode 15.2

* Fixed buffer overrun

* Xcode 15.2

* comments

* demo scheme

* delete dead code

* Fix JSON converion

* Fix error output

* Support console logs when events occur

* Store SDK version in sessions

* these tests

* results

* maybe don’t wait

* or do

* yeah don’t

* warnings and todos

* dropped unneeded #availability

* Contextual info on events in console

* WIP refactoring forms SwiftUI

* removed fonts

* cleanup

* parra logo button

* Maybe fixed tests 🤞
  • Loading branch information
mickmaccallum authored Jan 20, 2024
1 parent 9080a0b commit ece4cf2
Show file tree
Hide file tree
Showing 337 changed files with 16,777 additions and 5,771 deletions.
126 changes: 126 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# TODO:
# 1. PARRA_TEST_OUTPUT_DIRECTORY not working

orbs:
# ruby: circleci/[email protected]
macos: circleci/[email protected]
git-shallow-clone: guitarrapc/[email protected]
bun: ksylvest/[email protected]

commands:
common:
steps:
- git-shallow-clone/checkout:
depth: 1
fetch_depth: 1
# Enable this if we get errors related to GitHub RSA failure during clone.
# keyscan_github: true
no_tags: true
- attach_workspace:
at: .
- bun/install
- run:
name: Install NPM Dependencies
command: bun install --frozen-lockfile
load-env-vars:
steps:
- run:
name: Loading Environment Variables
command: |
cat bash.env >> $BASH_ENV
printenv
run-command-and-persist-variables:
parameters:
title:
type: string
command:
type: string
variables:
type: string # CSV of variables to persist
background:
type: boolean
default: false
steps:
- run:
name: << parameters.title >>
command: |
# Important to source from the command that we're executing to store env vars that are
# exported in the command.
. << parameters.command >>
# Iterate over variables and persist them
IFS=',' read -ra ADDR \<<< "<< parameters.variables >>"
for i in "${ADDR[@]}"; do
value=$(eval echo \$$i)
echo "Persisting variable: $i with value: $value"
echo "export $i=$value" >> $BASH_ENV
done
printenv
cp $BASH_ENV bash.env
background: << parameters.background >>

prepare_ios_prerequisites:
steps:
- run:
name: Install Brew Dependencies
command: ./cli.sh ci --install-brew-dependencies
# - run-command-and-persist-variables:
# title: Preboot Simulator
# command: ./cli/bin/preboot-simulator.sh
# variables: PARRA_TEST_DEVICE_UDID
# # The time saved by running this in the background is negated by the increased time the
# # build-for-testing script will take if a simulator is mid booted when it starts.
# background: false
- run:
name: Extract ASC Credential
command: |
dirname $PARRA_ASC_API_KEY_PATH | xargs mkdir -p
echo $PARRA_ASC_API_KEY | base64 --decode > $PARRA_ASC_API_KEY_PATH
# - run:
# name: Disable Simulator Hardware Keyboard
# command: ./cli.sh ci --disable-simulator-hardware-keyboard
# - ruby/install-deps: # Don't need to set bundler-version, ORB looks for Gemfile.lock by default.
# path: /tmp/workspace/vendor
# include-branch-in-cache-key: false

executors:
macos-m1-test-runner:
macos:
xcode: 15.2.0
resource_class: macos.m1.medium.gen1
environment:
PARRA_TEST_DERIVED_DATA_DIRECTORY: build/unit-tests/derivedData
PARRA_TEST_OUTPUT_DIRECTORY: artifacts/unit-tests
PARRA_TEST_PROJECT_NAME: ./Parra.xcodeproj
PARRA_TEST_SCHEME_NAME: Parra
PARRA_TEST_CONFIGURATION: Debug
PARRA_TEST_DEVICE_NAME: iPhone 15
PARRA_TEST_DEVICE_OS_VERSION: 17.2
PARRA_TEST_DESTINATION: platform=iOS Simulator,name=iPhone 15,OS=17.2
PARRA_ASC_API_KEY_PATH: ./artifacts/asc-key.p8
working_directory: /tmp/workspace

version: 2.1
jobs:
build-and-test:
executor: macos-m1-test-runner
steps:
- common
- prepare_ios_prerequisites
- run:
name: Build for Testing
command: ./cli.sh tests --build --log-level debug
# - macos/wait-until-simulator-booted:
# device-udid-var: PARRA_TEST_DEVICE_UDID
- run:
name: Run Unit Tests
command: ./cli.sh tests --run --log-level debug
- store_test_results:
path: build/unit-tests/derivedData/Logs/Test

workflows:
run-unit-tests:
jobs:
- build-and-test
41 changes: 41 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const ignorePatternsForDirectories = (dirs) => {
return dirs.map((dir) => `**/${dir}/*`);
};

module.exports = {
root: true,
env: {
browser: false,
es2021: true,
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
overrides: [
{
env: {
node: true,
},
files: ['.eslintrc.{js,cjs}'],
parserOptions: {
sourceType: 'script',
},
},
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'unused-imports'],
rules: {
'no-unused-vars': 'off', // or "@typescript-eslint/no-unused-vars": "off",
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
},
ignorePatterns: [
...ignorePatternsForDirectories([
'node_modules',
'build',
'dist',
'vendor',
]),
],
};
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# Set the following locally
# git config diff.lockb.textconv bun
# git config diff.lockb.binary true
*.lockb binary diff=lockb
26 changes: 0 additions & 26 deletions .github/workflows/ios.yml

This file was deleted.

27 changes: 6 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Created by https://www.toptal.com/developers/gitignore/api/macos,cocoapods,xcode,swift,objective-c,reactnative
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,cocoapods,xcode,swift,objective-c,reactnative

Expand All @@ -19,7 +18,6 @@ Pods/
# Icon must end with two \r
Icon


# Thumbnails
._*

Expand Down Expand Up @@ -125,7 +123,7 @@ __generated__
*.class

# Generated files
bin/
/bin/
gen/
out/
# Uncomment the following line in case you need and you don't have the release build type files in your app
Expand Down Expand Up @@ -276,8 +274,8 @@ bower_components
build/Release

# Dependency directories
node_modules/
jspm_packages/
**/node_modules/
**/jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
Expand Down Expand Up @@ -321,7 +319,7 @@ out

# Nuxt.js build / generate output
.nuxt
dist
**/dist

# Gatsby files
.cache/
Expand Down Expand Up @@ -358,9 +356,6 @@ dist
# Xcode
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore




## Gcc Patch
/*.gcno

Expand All @@ -379,11 +374,6 @@ dist
# Xcode
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore






## Playgrounds
timeline.xctimeline
playground.xcworkspace
Expand Down Expand Up @@ -412,7 +402,6 @@ playground.xcworkspace
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts


# Accio dependency management
Dependencies/
.accio/
Expand All @@ -423,20 +412,14 @@ Dependencies/
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control


# Code Injection
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode


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





### Xcode Patch ###
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
Expand All @@ -446,3 +429,5 @@ Dependencies/

# End of https://www.toptal.com/developers/gitignore/api/macos,cocoapods,xcode,swift,objective-c,reactnative
/.vscode/settings.json
/buildlog
/artifacts
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
21.4.0
18 changes: 18 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Ignore artifacts:
build
coverage

# Ignore all HTML files:
**/*.html

**/.git
**/.svn
**/.hg
**/node_modules

**/.git
**/.svn
**/.hg

**/dist
**/build
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"bracketSpacing": true,
"arrowParens": "always",
"printWidth": 80
}
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.1.4
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"bierner.github-markdown-preview",
"bierner.markdown-preview-github-styles",
"circleci.circleci",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint"
]
}
34 changes: 34 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"configurations": [
{
"name": "Build Tests",
"type": "node",
"request": "launch",

// Debug current file in VSCode
"program": "${file}",

/*
Path to tsx binary
Assuming locally installed
*/
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/tsx",

/*
Open terminal when debugging starts (Optional)
Useful to see console.logs
*/
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",

// Files to exclude from debugger (e.g. call stack)
"skipFiles": [
// Node.js internal core modules
"<node_internals>/**",

// Ignore all dependencies (optional)
"${workspaceFolder}/node_modules/**"
]
}
]
}
Loading

0 comments on commit ece4cf2

Please sign in to comment.