Skip to content

Commit

Permalink
Add install-tools.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
waliid committed Nov 7, 2024
1 parent 09e0e62 commit d91ce8c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 62 deletions.
91 changes: 29 additions & 62 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
name: CI
on: [pull_request]
env:
macos_ci_setup_token: ${{ secrets.MACOS_CI_SETUP_TOKEN }}
token: ${{ secrets.MACOS_CI_SETUP_TOKEN }}
vm_name: sequoia-for-pillarbox
vm_image: ghcr.io/cirruslabs/macos-sequoia-xcode:latest
branch_name: ${{ github.head_ref }}
ci_script_path: ${{ github.workspace }}/.github/workflows/scripts
repo_url: |
https://${{ secrets.MACOS_CI_SETUP_TOKEN }}\
@github.com/${{ github.repository }}.git
jobs:
install-tools:
runs-on:
Expand All @@ -16,70 +20,35 @@ jobs:
steps:
- name: Clone macos-ci-setup repository
run: |
rm -rf ~/macos-ci-setup
rm -rf ../macos-ci-setup
git clone -b add-scripts \
https://${{ env.macos_ci_setup_token }}\
@github.com/SRGSSR/macos-ci-setup.git ~/macos-ci-setup
https://${{ env.token }}\
@github.com/SRGSSR/macos-ci-setup.git ../macos-ci-setup
- name: Runner labels
id: runner-group-label
run: |
runner_group_label=\
$(~/macos-ci-setup/runner-group-label.sh $RUNNER_NAME)
$(../macos-ci-setup/runner-group-label.sh $RUNNER_NAME)
echo "runner_group_label=$runner_group_label" >> $GITHUB_OUTPUT
- name: Install tools
run: |
cd ~/macos-ci-setup
./brew-fetch.sh ${{ env.vm_name }} \
"swiftlint shellcheck markdownlint-cli yamllint ffmpeg"
./create-vm-for-project.sh ${{ env.vm_name }} ${{ env.vm_image }}
./clone-repo-in-vm.sh ${{ env.vm_name }} ${{ env.branch_name }} \
"https://${{ env.macos_ci_setup_token }}\
@github.com/${{ github.repository }}.git"
./run-vm-shell-command.sh ${{ env.vm_name }} \
"brew install --quiet \
swiftlint shellcheck markdownlint-cli yamllint ffmpeg"
./run-vm-shell-command.sh ${{ env.vm_name }} \
"rbenv install --skip-existing 3.3.5"
./run-vm-shell-command.sh ${{ env.vm_name }} \
"echo 'export PATH=\"$HOME/.rbenv/bin:$PATH\"' >> ~/.zshrc"
- name: Checkout code
uses: actions/checkout@v4

./run-vm-shell-command.sh ${{ env.vm_name }} \
"rbenv init - >> ~/.zshrc"
./run-vm-shell-command.sh ${{ env.vm_name }} \
"rbenv global 3.3.5"
./run-vm-shell-command.sh ${{ env.vm_name }} \
"sudo gem install bundler -v 2.5.22"
./run-vm-shell-command.sh ${{ env.vm_name }} \
"curl --location \
https://github.com/shaka-project/shaka-packager\
/releases/download/v3.2.0/packager-osx-arm64 -o \
/opt/homebrew/bin/shaka-packager"
./run-vm-shell-command.sh ${{ env.vm_name }} \
"chmod a+x /opt/homebrew/bin/shaka-packager"
./run-vm-shell-command.sh ${{ env.vm_name }} \
"source ~/.zshrc"
- name: Install tools
run: |
${{ env.ci_script_path }}/install-tools.sh \
${{ env.vm_name }} ${{ env.vm_image }} \
${{ env.branch_name }} ${{ env.repo_url }} "test"
run-streams:
needs: install-tools
runs-on: ${{ needs.install-tools.outputs.runner_group_label }}
steps:
- name: Run test streams
run: |
~/macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \
../macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \
"cd ~/_repo && make test-streams-start"
setup-project:
Expand All @@ -88,29 +57,27 @@ jobs:
steps:
- name: Setup project
run: |
cd ~/macos-ci-setup
./run-vm-shell-command.sh ${{ env.vm_name }} \
../macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \
"cd ~/_repo && rm -rf Configuration"
./run-vm-shell-command.sh ${{ env.vm_name }} \
../macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \
"cd ~/_repo && Scripts/checkout-configuration.sh \
https://${{ env.macos_ci_setup_token }}\
https://${{ env.token }}\
@github.com/SRGSSR/pillarbox-apple-configuration.git \
certificate HEAD Configuration"
./run-vm-shell-command.sh ${{ env.vm_name }} \
../macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \
"security unlock-keychain -p 'admin' \
~/Library/Keychains/login.keychain-db && \
security import ~/_repo/Configuration/6YXTQTG8JJ_development.p12 \
-k ~/Library/Keychains/login.keychain-db \
-P '6YXTQTG8JJ' -T /usr/bin/security -T /usr/bin/codesign"
./run-vm-shell-command.sh ${{ env.vm_name }} \
../macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \
"security set-key-partition-list -S apple-tool:,apple: -s -k 'admin' \
~/Library/Keychains/login.keychain-db"
./run-vm-shell-command.sh ${{ env.vm_name }} \
../macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \
"cd ~/_repo && make setup"
check-quality:
Expand All @@ -119,7 +86,7 @@ jobs:
steps:
- name: Run the quality check
run: |
~/macos-ci-setup/run-vm-shell-command.sh \
../macos-ci-setup/run-vm-shell-command.sh \
${{ env.vm_name }} "cd ~/_repo && make check-quality"
resolve-spm-dependencies:
Expand All @@ -128,7 +95,7 @@ jobs:
steps:
- name: Resolve SPM dependencies
run: |
~/macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \
../macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \
"cd ~/_repo && xcodebuild -resolvePackageDependencies -verbose"
test-ios:
Expand All @@ -137,7 +104,7 @@ jobs:
steps:
- name: Run the iOS tests
run: |
~/macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \
../macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \
"cd ~/_repo && make test-ios"
test-tvos:
Expand All @@ -146,7 +113,7 @@ jobs:
steps:
- name: Run the tvOS tests
run: |
~/macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \
../macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \
"cd ~/_repo && make test-tvos"
archive-demo-ios:
Expand All @@ -155,7 +122,7 @@ jobs:
steps:
- name: Archive the iOS demo
run: |
~/macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \
../macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \
"cd ~/_repo && security unlock-keychain -p 'admin' \
~/Library/Keychains/login.keychain-db && make archive-demo-ios"
Expand All @@ -165,7 +132,7 @@ jobs:
steps:
- name: Archive the tvOS demo
run: |
~/macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \
../macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \
"cd ~/_repo && security unlock-keychain -p 'admin' \
~/Library/Keychains/login.keychain-db && make archive-demo-tvos"
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/scripts/install-tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

vm_name="$1"
vm_image="$2"
branch_name="$3"
repo_url="$4"
script_path="$5"

echo "=========> Debugging variables <========"
echo "script_path: $script_path"
echo "vm_name: $vm_name"
echo "vm_image: $vm_image"
echo "branch_name: $branch_name"
echo "repo_url: $repo_url"

"$script_path/brew-fetch.sh" "$vm_name" "swiftlint shellcheck markdownlint-cli yamllint ffmpeg"

"$script_path/create-vm-for-project.sh" "$vm_name" "$vm_image"
"$script_path/clone-repo-in-vm.sh" "$vm_name" "$branch_name" "$repo_url"

"$script_path/run-vm-shell-command.sh" "$vm_name" "brew install --quiet swiftlint shellcheck markdownlint-cli yamllint ffmpeg"
"$script_path/run-vm-shell-command.sh" "$vm_name" "rbenv install --skip-existing 3.3.5"
"$script_path/run-vm-shell-command.sh" "$vm_name" "echo 'export PATH=\"$HOME/.rbenv/bin:\$PATH\"' >> ~/.zshrc"
"$script_path/run-vm-shell-command.sh" "$vm_name" "rbenv init - >> ~/.zshrc"
"$script_path/run-vm-shell-command.sh" "$vm_name" "rbenv global 3.3.5"
"$script_path/run-vm-shell-command.sh" "$vm_name" "sudo gem install bundler -v 2.5.22"
"$script_path/run-vm-shell-command.sh" "$vm_name" "curl --location https://github.com/shaka-project/shaka-packager/releases/download/v3.2.0/packager-osx-arm64 -o /opt/homebrew/bin/shaka-packager"
"$script_path/run-vm-shell-command.sh" "$vm_name" "chmod a+x /opt/homebrew/bin/shaka-packager"
"$script_path/run-vm-shell-command.sh" "$vm_name" "source ~/.zshrc"

0 comments on commit d91ce8c

Please sign in to comment.