Skip to content

Commit

Permalink
ci: using nix everywhere in the ci
Browse files Browse the repository at this point in the history
  • Loading branch information
sandipndev committed Mar 10, 2024
1 parent 4895ec3 commit 271dda8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 41 deletions.
49 changes: 11 additions & 38 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,7 @@ jobs:
steps:
- uses: actions/checkout@v2

# Node, Ruby, Java, Android Sdk
- uses: actions/setup-node@v2
with:
node-version: 20
- run: npm i -g yarn
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- uses: actions/setup-java@v2
with:
java-version: 17
distribution: temurin
- uses: android-actions/setup-android@v3

# Caching
- uses: gradle/actions/setup-gradle@v3
- uses: DeterminateSystems/magic-nix-cache-action@v2
- uses: actions/cache@v2
with:
Expand All @@ -42,35 +27,27 @@ jobs:
restore-keys: |
${{ runner.os }}-deps-
# Installations
- name: Install Node Modules and Pods
run: yarn install
env:
LANG: en_US.UTF-8
LC_ALL: en_US.UTF-8
- run: nix develop -c 'yarn install'

# Metro
- name: Start Metro
run: |
yarn start &
nix develop -c 'yarn start' &
echo "METRO_PID=$!" >> $GITHUB_ENV
# Build
- run: yarn e2e:build ios.sim.debug
- run: yarn e2e:build android.emu.debug
- run: nix develop -c 'yarn e2e:build ios.sim.debug'
- run: nix develop -c 'yarn e2e:build android.emu.debug'

# Start Tilt
- name: Tilt CI
run: |
for i in {1..5}; do
echo "Tilt CI attempt $i"
nix develop -c sh -c 'cd dev && tilt ci' && exit 0 || sleep 15
nix develop -c 'cd dev && tilt ci' && exit 0 || sleep 15
done
exit 1
# Tests on iOS Simulator
- name: Run Detox Tests on iOS Simulator
run: yarn e2e:test ios.sim.debug -d -R 5 --take-screenshots all --record-videos all --record-logs all --artifacts-location ios-recordings
run: nix develop -c 'yarn e2e:test ios.sim.debug -d -R 5 --take-screenshots all --record-videos all --record-logs all --artifacts-location ios-recordings'

- run: killall Simulator
if: always()
Expand All @@ -85,20 +62,16 @@ jobs:
# Tests on Android Emulator
- name: Start Android Emulator
run: |
sdkmanager --install 'build-tools;34.0.0' platform-tools > /dev/null
sdkmanager --install emulator --channel=0 > /dev/null
sdkmanager --install 'system-images;android-34;google_apis_playstore;arm64-v8a' --channel=0 > /dev/null
echo no | avdmanager create avd --force -n Pixel_API_34 --abi 'google_apis_playstore/arm64-v8a' --package 'system-images;android-34;google_apis_playstore;arm64-v8a' --device 'pixel_6a'
emulator -avd Pixel_API_34 -gpu swiftshader_indirect -no-boot-anim &
adb wait-for-device
nix develop -c 'make emulator' &
nix develop -c 'adb wait-for-device'
- name: Run Detox Tests on Android Emulator
run: yarn e2e:test android.emu.debug -d -R 5 --take-screenshots all --record-videos all --record-logs all --artifacts-location android-recordings
run: nix develop -c 'yarn e2e:test android.emu.debug -d -R 5 --take-screenshots all --record-videos all --record-logs all --artifacts-location android-recordings'

- name: Kill Android Emulator
if: always()
continue-on-error: true
run: adb emu kill
run: nix develop -c 'adb emu kill'

- uses: actions/upload-artifact@v4
if: always()
Expand All @@ -116,5 +89,5 @@ jobs:
if: always()
continue-on-error: true
run: |
nix develop -c sh -c 'cd dev && tilt down' || true
cd dev && tilt down || true
docker rm -f $(docker ps -aq)
8 changes: 6 additions & 2 deletions docs/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@ You can download XCode and Simulator blazingly fast and let the CLI do all of th
Here are the commands that do it:

```bash
xcodes install 15.3 # Or whatever version direnv tells you about
xcodes runtimes install "iOS 17.4" # Or the latest iOS out there
XCODE_VERSION="15.3" # Or whatever version direnv tells you about
IOS_VERSION="17.4"
xcodes install $XCODE_VERSION
xcodes select $XCODE_VERSION
xcodes runtimes install "iOS $IOS_VERSION"
```
Xcodes install for the first time prompts you for Apple ID and Password. This is because Apple's license for XCode prohibits distribution of XCode from other servers than their own. And downloads from it can only work if you are authenticated. Hence, to use XCode, you need an Apple ID.
Once the installs are done, you can `xcodes signout` to be on the safer side.
3 changes: 2 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@

devShells.default = pkgs.mkShell {
inherit nativeBuildInputs;
LANG = "en_US.UTF-8";

ANDROID_HOME = "${pkgs.android-sdk}/share/android-sdk";
ANDROID_SDK_ROOT = "${pkgs.android-sdk}/share/android-sdk";
Expand All @@ -129,7 +130,7 @@
XCODE_VERSION="15.3"
XCODE_BUILD="15E204a" # When updating xcode version, get it by running xcodes installed
if [[ $(uname) == "Darwin" ]]; then
if [[ $(uname) == "Darwin" ]] && [[ -z "$CI" ]]; then
if ! xcodes installed | grep "$XCODE_VERSION ($XCODE_BUILD) (Selected)" -q; then
echo -e "\e[1;33m================================================\e[0m"
echo -e "\e[1;33mXCode $XCODE_VERSION was not found or is not selected\e[0m"
Expand Down

0 comments on commit 271dda8

Please sign in to comment.