Skip to content

Commit

Permalink
Merge branch 'nightscout:feat/dana' into feat/dana
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiaanv authored Sep 9, 2024
2 parents 7443973 + d76f549 commit 4837fea
Show file tree
Hide file tree
Showing 15 changed files with 290 additions and 218 deletions.
28 changes: 20 additions & 8 deletions .github/workflows/add_identifiers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,39 @@ jobs:
name: Validate
uses: ./.github/workflows/validate_secrets.yml
secrets: inherit

identifiers:
name: Add Identifiers
needs: validate
runs-on: macos-13
runs-on: macos-14
steps:
# Uncomment to manually select Xcode version if needed
#- name: Select Xcode version
# run: "sudo xcode-select --switch /Applications/Xcode_15.0.1.app/Contents/Developer"
# Uncomment to manually select latest Xcode if needed
#- name: Select Latest Xcode
# run: "sudo xcode-select --switch /Applications/Xcode_13.0.app/Contents/Developer"

# Checks-out the repo
- name: Checkout Repo
uses: actions/checkout@v4

# Patch Fastlane Match to not print tables
- name: Patch Match Tables
run: find /usr/local/lib/ruby/gems -name table_printer.rb | xargs sed -i "" "/puts(Terminal::Table.new(params))/d"

run: |
TABLE_PRINTER_PATH=$(ruby -e 'puts Gem::Specification.find_by_name("fastlane").gem_dir')/match/lib/match/table_printer.rb
if [ -f "$TABLE_PRINTER_PATH" ]; then
sed -i "" "/puts(Terminal::Table.new(params))/d" "$TABLE_PRINTER_PATH"
else
echo "table_printer.rb not found"
exit 1
fi
# Install project dependencies
- name: Install Project Dependencies
run: bundle install

# Sync the GitHub runner clock with the Windows time server (workaround as suggested in https://github.com/actions/runner/issues/2996)
- name: Sync clock
run: sudo sntp -sS time.windows.com

# Create or update identifiers for app
- name: Fastlane Provision
run: bundle exec fastlane identifiers
Expand Down
326 changes: 179 additions & 147 deletions .github/workflows/build_trio.yml

Large diffs are not rendered by default.

23 changes: 17 additions & 6 deletions .github/workflows/create_certs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,35 @@ jobs:
certificates:
name: Create Certificates
needs: validate
runs-on: macos-13
runs-on: macos-14
steps:
# Uncomment to manually select Xcode version if needed
- name: Select Xcode version
run: "sudo xcode-select --switch /Applications/Xcode_15.0.1.app/Contents/Developer"
# Uncomment to manually select latest Xcode if needed
#- name: Select Latest Xcode
# run: "sudo xcode-select --switch /Applications/Xcode_13.0.app/Contents/Developer"

# Checks-out the repo
- name: Checkout Repo
uses: actions/checkout@v4

# Patch Fastlane Match to not print tables
- name: Patch Match Tables
run: find /usr/local/lib/ruby/gems -name table_printer.rb | xargs sed -i "" "/puts(Terminal::Table.new(params))/d"
run: |
TABLE_PRINTER_PATH=$(ruby -e 'puts Gem::Specification.find_by_name("fastlane").gem_dir')/match/lib/match/table_printer.rb
if [ -f "$TABLE_PRINTER_PATH" ]; then
sed -i "" "/puts(Terminal::Table.new(params))/d" "$TABLE_PRINTER_PATH"
else
echo "table_printer.rb not found"
exit 1
fi
# Install project dependencies
- name: Install Project Dependencies
run: bundle install

# Sync the GitHub runner clock with the Windows time server (workaround as suggested in https://github.com/actions/runner/issues/2996)
- name: Sync clock
run: sudo sntp -sS time.windows.com

# Create or update certificates for app
- name: Create Certificates
run: bundle exec fastlane certs
Expand Down
47 changes: 25 additions & 22 deletions .github/workflows/validate_secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: [workflow_call, workflow_dispatch]
jobs:
validate-access-token:
name: Access
runs-on: macos-13
runs-on: macos-14
env:
GH_PAT: ${{ secrets.GH_PAT }}
GH_TOKEN: ${{ secrets.GH_PAT }}
Expand All @@ -16,14 +16,14 @@ jobs:
id: access-token
run: |
# Validate Access Token
# Ensure that gh exit codes are handled when output is piped.
set -o pipefail
# Define patterns to validate the access token (GH_PAT) and distinguish between classic and fine-grained tokens.
GH_PAT_CLASSIC_PATTERN='^ghp_[a-zA-Z0-9]{36}$'
GH_PAT_FINE_GRAINED_PATTERN='^github_pat_[a-zA-Z0-9]{22}_[a-zA-Z0-9]{59}$'
# Validate Access Token (GH_PAT)
if [ -z "$GH_PAT" ]; then
failed=true
Expand Down Expand Up @@ -65,26 +65,26 @@ jobs:
echo "has_workflow_permission=true" >> $GITHUB_OUTPUT
fi
fi
# Exit unsuccessfully if secret validation failed.
if [ $failed ]; then
exit 2
fi
validate-match-secrets:
name: Match-Secrets
needs: validate-access-token
runs-on: macos-13
runs-on: macos-14
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
steps:
- name: Validate Match-Secrets
run: |
# Validate Match-Secrets
# Ensure that gh exit codes are handled when output is piped.
set -o pipefail
# If a Match-Secrets repository does not exist, attempt to create one.
if ! visibility=$(gh repo view ${{ github.repository_owner }}/Match-Secrets --json visibility | jq --raw-output '.visibility | ascii_downcase'); then
echo "A '${{ github.repository_owner }}/Match-Secrets' repository could not be found using the GH_PAT secret. Attempting to create one..."
Expand All @@ -103,16 +103,16 @@ jobs:
else
echo "Found a private '${{ github.repository_owner }}/Match-Secrets' repository to use."
fi
# Exit unsuccessfully if secret validation failed.
if [ $failed ]; then
exit 2
fi
validate-fastlane-secrets:
name: Fastlane
needs: [validate-access-token, validate-match-secrets]
runs-on: macos-13
runs-on: macos-14
env:
GH_PAT: ${{ secrets.GH_PAT }}
GH_TOKEN: ${{ secrets.GH_PAT }}
Expand All @@ -125,14 +125,17 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v4

# Install project dependencies
- name: Install Project Dependencies
run: bundle install

# Sync the GitHub runner clock with the Windows time server (workaround as suggested in https://github.com/actions/runner/issues/2996)
- name: Sync clock
run: sudo sntp -sS time.windows.com

- name: Validate Fastlane Secrets
run: |
# Validate Fastlane Secrets
# Validate TEAMID
if [ -z "$TEAMID" ]; then
failed=true
Expand All @@ -144,34 +147,34 @@ jobs:
failed=true
echo "::error::The TEAMID secret is set but invalid. Verify that it is set correctly (only uppercase letters and numbers) and try again."
fi
# Validate MATCH_PASSWORD
if [ -z "$MATCH_PASSWORD" ]; then
failed=true
echo "::error::The MATCH_PASSWORD secret is unset or empty. Set it and try again."
fi
# Ensure that fastlane exit codes are handled when output is piped.
set -o pipefail
# Validate FASTLANE_ISSUER_ID, FASTLANE_KEY_ID, and FASTLANE_KEY
FASTLANE_KEY_ID_PATTERN='^[A-Z0-9]+$'
FASTLANE_ISSUER_ID_PATTERN='^\{?[A-F0-9a-f]{8}-[A-F0-9a-f]{4}-[A-F0-9a-f]{4}-[A-F0-9a-f]{4}-[A-F0-9a-f]{12}\}?$'
if [ -z "$FASTLANE_ISSUER_ID" ] || [ -z "$FASTLANE_KEY_ID" ] || [ -z "$FASTLANE_KEY" ]; then
failed=true
[ -z "$FASTLANE_ISSUER_ID" ] && echo "::error::The FASTLANE_ISSUER_ID secret is unset or empty. Set it and try again."
[ -z "$FASTLANE_KEY_ID" ] && echo "::error::The FASTLANE_KEY_ID secret is unset or empty. Set it and try again."
[ -z "$FASTLANE_KEY" ] && echo "::error::The FASTLANE_KEY secret is unset or empty. Set it and try again."
elif [ ${#FASTLANE_KEY_ID} -ne 10 ]; then
failed=true
echo "::error::The FASTLANE_KEY_ID secret is set but has wrong length. Verify that you copied it correctly from the 'Keys' tab at https://appstoreconnect.apple.com/access/api and try again."
echo "::error::The FASTLANE_KEY_ID secret is set but has wrong length. Verify that you copied it correctly from the 'Keys' tab at https://appstoreconnect.apple.com/access/integrations/api and try again."
elif ! [[ $FASTLANE_KEY_ID =~ $FASTLANE_KEY_ID_PATTERN ]]; then
failed=true
echo "::error::The FASTLANE_KEY_ID secret is set but invalid. Verify that you copied it correctly from the 'Keys' tab at https://appstoreconnect.apple.com/access/api and try again."
echo "::error::The FASTLANE_KEY_ID secret is set but invalid. Verify that you copied it correctly from the 'Keys' tab at https://appstoreconnect.apple.com/access/integrations/api and try again."
elif ! [[ $FASTLANE_ISSUER_ID =~ $FASTLANE_ISSUER_ID_PATTERN ]]; then
failed=true
echo "::error::The FASTLANE_ISSUER_ID secret is set but invalid. Verify that you copied it correctly from the 'Keys' tab at https://appstoreconnect.apple.com/access/api and try again."
echo "::error::The FASTLANE_ISSUER_ID secret is set but invalid. Verify that you copied it correctly from the 'Keys' tab at https://appstoreconnect.apple.com/access/integrations/api and try again."
elif ! echo "$FASTLANE_KEY" | openssl pkcs8 -nocrypt >/dev/null; then
failed=true
echo "::error::The FASTLANE_KEY secret is set but invalid. Verify that you copied it correctly from the API Key file (*.p8) you downloaded and try again."
Expand All @@ -187,7 +190,7 @@ jobs:
echo "::error::Unable to create a valid authorization token for the App Store Connect API. Verify that the FASTLANE_ISSUER_ID, FASTLANE_KEY_ID, and FASTLANE_KEY secrets are set correctly and try again."
fi
fi
# Exit unsuccessfully if secret validation failed.
if [ $failed ]; then
exit 2
Expand Down
4 changes: 4 additions & 0 deletions FreeAPS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@
BD2B464E0745FBE7B79913F4 /* NightscoutConfigProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3BF768BD6264FF7D71D66767 /* NightscoutConfigProvider.swift */; };
BDF530D82B40F8AC002CAF43 /* LockScreenView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDF530D72B40F8AC002CAF43 /* LockScreenView.swift */; };
BF1667ADE69E4B5B111CECAE /* ManualTempBasalProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 680C4420C9A345D46D90D06C /* ManualTempBasalProvider.swift */; };
C20BC6CE2C66FBFD002BC1C6 /* Rounding.swift in Sources */ = {isa = PBXBuildFile; fileRef = C20BC6CD2C66FBFD002BC1C6 /* Rounding.swift */; };
C967DACD3B1E638F8B43BE06 /* ManualTempBasalStateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFCFE0781F9074C2917890E8 /* ManualTempBasalStateModel.swift */; };
CA370FC152BC98B3D1832968 /* BasalProfileEditorRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8BCB0C37DEB5EC377B9612 /* BasalProfileEditorRootView.swift */; };
CC6C406E2ACDD69E009B8058 /* RawFetchedProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC6C406D2ACDD69E009B8058 /* RawFetchedProfile.swift */; };
Expand Down Expand Up @@ -817,6 +818,7 @@
BDF530D72B40F8AC002CAF43 /* LockScreenView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LockScreenView.swift; sourceTree = "<group>"; };
BF8BCB0C37DEB5EC377B9612 /* BasalProfileEditorRootView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = BasalProfileEditorRootView.swift; sourceTree = "<group>"; };
C19984D62EFC0035A9E9644D /* BolusProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = BolusProvider.swift; sourceTree = "<group>"; };
C20BC6CD2C66FBFD002BC1C6 /* Rounding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Rounding.swift; sourceTree = "<group>"; };
C377490C77661D75E8C50649 /* ManualTempBasalRootView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ManualTempBasalRootView.swift; sourceTree = "<group>"; };
C8D1A7CA8C10C4403D4BBFA7 /* BolusDataFlow.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = BolusDataFlow.swift; sourceTree = "<group>"; };
CC6C406D2ACDD69E009B8058 /* RawFetchedProfile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RawFetchedProfile.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1651,6 +1653,7 @@
FEFFA7A12929FE49007B8193 /* UIDevice+Extensions.swift */,
CEA4F62229BE10F70011ADF7 /* SavitzkyGolayFilter.swift */,
DD1DB7CB2BECCA1F0048B367 /* BuildDetails.swift */,
C20BC6CD2C66FBFD002BC1C6 /* Rounding.swift */,
);
path = Helpers;
sourceTree = "<group>";
Expand Down Expand Up @@ -2724,6 +2727,7 @@
38DAB28A260D349500F74C1A /* FetchGlucoseManager.swift in Sources */,
38F37828261260DC009DB701 /* Color+Extensions.swift in Sources */,
3811DE3F25C9D4A100A708ED /* SettingsStateModel.swift in Sources */,
C20BC6CE2C66FBFD002BC1C6 /* Rounding.swift in Sources */,
CE7CA3582A064E2F004BE681 /* ListStateView.swift in Sources */,
193F6CDD2A512C8F001240FD /* Loops.swift in Sources */,
38B4F3CB25E502E200E76A18 /* WeakObjectSet.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion FreeAPS/Resources/javascript/bundle/autosens.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion FreeAPS/Resources/javascript/bundle/autotune-prep.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion FreeAPS/Resources/javascript/bundle/iob.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion FreeAPS/Resources/javascript/bundle/meal.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion FreeAPS/Resources/javascript/bundle/profile.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions FreeAPS/Sources/Helpers/Rounding.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Foundation

func rounded(_ value: Decimal, scale: Int, roundingMode: NSDecimalNumber.RoundingMode) -> Decimal {
var result = Decimal()
var toRound = value
NSDecimalRound(&result, &toRound, scale, roundingMode)
return result
}
10 changes: 5 additions & 5 deletions FreeAPS/Sources/Models/BloodGlucose.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,27 @@ enum GlucoseUnits: String, JSON, Equatable {

extension Int {
var asMmolL: Decimal {
Decimal(self) * GlucoseUnits.exchangeRate
FreeAPS.rounded(Decimal(self) * GlucoseUnits.exchangeRate, scale: 1, roundingMode: .plain)
}
}

extension Decimal {
var asMmolL: Decimal {
self * GlucoseUnits.exchangeRate
FreeAPS.rounded(self * GlucoseUnits.exchangeRate, scale: 1, roundingMode: .plain)
}

var asMgdL: Decimal {
self / GlucoseUnits.exchangeRate
FreeAPS.rounded(self / GlucoseUnits.exchangeRate, scale: 0, roundingMode: .plain)
}
}

extension Double {
var asMmolL: Decimal {
Decimal(self) * GlucoseUnits.exchangeRate
FreeAPS.rounded(Decimal(self) * GlucoseUnits.exchangeRate, scale: 1, roundingMode: .plain)
}

var asMgdL: Decimal {
Decimal(self) / GlucoseUnits.exchangeRate
FreeAPS.rounded(Decimal(self) / GlucoseUnits.exchangeRate, scale: 0, roundingMode: .plain)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ extension AutotuneConfig {
.foregroundColor(.red)
}

Section {
Button {
replaceAlert = true
}
label: { Text("Save as your Normal Basal Rates") }
} header: {
Text("Replace Normal Basal")
}
/* Section {
Button {
replaceAlert = true
}
label: { Text("Save as your Normal Basal Rates") }
} header: {
Text("Replace Normal Basal")
} */
}
}
.onAppear(perform: configureView)
Expand Down
5 changes: 4 additions & 1 deletion oref0_source_version.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
oref0 branch: dev - git version: d1dfb70
oref0 branch: dev - git version: 363fd11

Last commits:
363fd11 Merge pull request #28 from bjornoleh/harmonise_defaults
2d695e1 index.js: set enableUAM to false, and remove whitespace in L11
8f5f820 Harmonise profile defaults with openaps/oref0
d1dfb70 Merge pull request #26 from MikePlante1/typo
d9f1662 fix `threshold_setting` typo
b454837 Merge pull request #24 from nightscout/Trio_renames
Expand Down
Loading

0 comments on commit 4837fea

Please sign in to comment.