diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67ed4659..9d362651 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,10 +2,15 @@ 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 }} + script_path: ${{ github.workspace }}/../macos-ci-setup + 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: @@ -16,62 +21,27 @@ jobs: steps: - name: Clone macos-ci-setup repository run: | - rm -rf ~/macos-ci-setup - + rm -rf ${{ env.script_path }} 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 ${{ env.script_path }} - name: Runner labels id: runner-group-label run: | runner_group_label=\ - $(~/macos-ci-setup/runner-group-label.sh $RUNNER_NAME) + $(${{ env.script_path }}/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 }} ${{ env.script_path }} run-streams: needs: install-tools @@ -79,7 +49,7 @@ jobs: steps: - name: Run test streams run: | - ~/macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \ + ${{ env.script_path }}/run-vm-shell-command.sh ${{ env.vm_name }} \ "cd ~/_repo && make test-streams-start" setup-project: @@ -88,29 +58,27 @@ jobs: steps: - name: Setup project run: | - cd ~/macos-ci-setup - - ./run-vm-shell-command.sh ${{ env.vm_name }} \ + ${{ env.script_path }}/run-vm-shell-command.sh ${{ env.vm_name }} \ "cd ~/_repo && rm -rf Configuration" - ./run-vm-shell-command.sh ${{ env.vm_name }} \ + ${{ env.script_path }}/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 }} \ + ${{ env.script_path }}/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 }} \ + ${{ env.script_path }}/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 }} \ + ${{ env.script_path }}/run-vm-shell-command.sh ${{ env.vm_name }} \ "cd ~/_repo && make setup" check-quality: @@ -119,7 +87,7 @@ jobs: steps: - name: Run the quality check run: | - ~/macos-ci-setup/run-vm-shell-command.sh \ + ${{ env.script_path }}/run-vm-shell-command.sh \ ${{ env.vm_name }} "cd ~/_repo && make check-quality" resolve-spm-dependencies: @@ -128,7 +96,7 @@ jobs: steps: - name: Resolve SPM dependencies run: | - ~/macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \ + ${{ env.script_path }}/run-vm-shell-command.sh ${{ env.vm_name }} \ "cd ~/_repo && xcodebuild -resolvePackageDependencies -verbose" test-ios: @@ -137,7 +105,7 @@ jobs: steps: - name: Run the iOS tests run: | - ~/macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \ + ${{ env.script_path }}/run-vm-shell-command.sh ${{ env.vm_name }} \ "cd ~/_repo && make test-ios" test-tvos: @@ -146,7 +114,7 @@ jobs: steps: - name: Run the tvOS tests run: | - ~/macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \ + ${{ env.script_path }}/run-vm-shell-command.sh ${{ env.vm_name }} \ "cd ~/_repo && make test-tvos" archive-demo-ios: @@ -155,7 +123,7 @@ jobs: steps: - name: Archive the iOS demo run: | - ~/macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \ + ${{ env.script_path }}/run-vm-shell-command.sh ${{ env.vm_name }} \ "cd ~/_repo && security unlock-keychain -p 'admin' \ ~/Library/Keychains/login.keychain-db && make archive-demo-ios" @@ -165,7 +133,7 @@ jobs: steps: - name: Archive the tvOS demo run: | - ~/macos-ci-setup/run-vm-shell-command.sh ${{ env.vm_name }} \ + ${{ env.script_path }}/run-vm-shell-command.sh ${{ env.vm_name }} \ "cd ~/_repo && security unlock-keychain -p 'admin' \ ~/Library/Keychains/login.keychain-db && make archive-demo-tvos" diff --git a/.github/workflows/scripts/install-tools.sh b/.github/workflows/scripts/install-tools.sh new file mode 100755 index 00000000..dafd63d3 --- /dev/null +++ b/.github/workflows/scripts/install-tools.sh @@ -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" \ No newline at end of file