Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DEVOPS-198] Run cleanup script on Mac M1 runners when job starts #657

Merged
merged 27 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d9d1539
TODOs
juliannguyen4 Aug 2, 2024
28a2553
note bug
juliannguyen4 Aug 2, 2024
7e15cc3
Add more todos
juliannguyen4 Aug 2, 2024
a2a1435
Build and test using setup-python and cleanup script
juliannguyen4 Aug 15, 2024
5c59c38
Dont clean up docker in workflow
juliannguyen4 Aug 15, 2024
a0b4935
Unlock keychain for building security image
juliannguyen4 Aug 15, 2024
e8d9561
Remove this step after unlocking keychain in prev workflow to see wha…
juliannguyen4 Aug 15, 2024
bda220d
intentionally lock keychain to reset
juliannguyen4 Aug 16, 2024
7f1f1a0
debug
juliannguyen4 Aug 16, 2024
3ba0424
print after configuring auth
juliannguyen4 Aug 16, 2024
f75c84a
Keychains
juliannguyen4 Aug 16, 2024
dd3fdb6
add useful comment
juliannguyen4 Aug 16, 2024
6542280
Update build-wheels.yml
juliannguyen4 Aug 16, 2024
1fd28e2
Update build-wheels.yml
juliannguyen4 Aug 16, 2024
19c656f
Try forcing arch for setup-python
juliannguyen4 Aug 16, 2024
866623f
Revert "Try forcing arch for setup-python"
juliannguyen4 Aug 16, 2024
6e15fe4
Build mac m1 wheels on github runners
juliannguyen4 Aug 16, 2024
212b1e9
Revert "Build mac m1 wheels on github runners"
juliannguyen4 Aug 16, 2024
51e4199
specify arm64
juliannguyen4 Aug 16, 2024
993ef24
Revert "specify arm64"
juliannguyen4 Aug 16, 2024
860393a
Build mac m1 wheels on github runners
juliannguyen4 Aug 16, 2024
75bbf40
fix
juliannguyen4 Aug 16, 2024
f153b5a
remove todos
juliannguyen4 Aug 19, 2024
f7eb7e4
Only install 3.8 for 3.8 test
juliannguyen4 Aug 19, 2024
4709b37
Update build-wheels.yml
juliannguyen4 Aug 19, 2024
b9287e3
fix
juliannguyen4 Aug 19, 2024
c09ceec
Update build-wheels.yml
juliannguyen4 Aug 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/actions/run-ee-server/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ runs:
steps:
- name: Install crudini to manipulate config.conf
# This will only work on the Github hosted runners.
# TODO: mac m1 self hosted runners do not have pipx installed by default
run: pipx install crudini --pip-args "-c ${{ github.workspace }}/.github/workflows/requirements.txt"
working-directory: .github/workflows
shell: bash
Expand Down
152 changes: 91 additions & 61 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,79 @@ jobs:
sha: ${{ github.sha }}
context: "Build wheels (${{ matrix.python }}-macosx_x86_64)"

# TODO: this needs refactoring. But for now, just reuse code from the macos x86 job
# There's already an open PR to refactor all this code for building wheels and the sdist
macOS-m1:
strategy:
fail-fast: false
matrix:
python: [
"cp38",
"cp39",
"cp310",
"cp311",
"cp312"
]
runs-on: macos-14
steps:
- name: Show job status for commit
uses: myrotvorets/set-commit-status-action@v2.0.0
if: ${{ github.event_name != 'push' && github.event_name != 'pull_request' }}
with:
sha: ${{ github.sha }}
context: "Build wheels (${{ matrix.python }}-macosx_arm64)"

- uses: actions/checkout@v4
with:
submodules: recursive
ref: ${{ inputs.ref }}
fetch-depth: 0

- name: Set unoptimize flag
if: ${{ inputs.apply-no-optimizations }}
run: echo "UNOPTIMIZED=1" >> $GITHUB_ENV

- name: Set include dsym flag
if: ${{ inputs.include-debug-info-for-macos }}
run: echo "INCLUDE_DSYM=1" >> $GITHUB_ENV

# Install native version of Python 3.8 on arm64
# The default Python 3.8 install used by cibuildwheel is for x86_64
# https://cibuildwheel.pypa.io/en/stable/faq/#macos-building-cpython-38-wheels-on-arm64
- uses: actions/setup-python@v5
with:
python-version: 3.8
if: runner.os == 'macOS' && runner.arch == 'ARM64' && matrix.python == 'cp38'

- name: Build wheel
uses: pypa/cibuildwheel@v2.19.2
env:
CIBW_BUILD: ${{ matrix.python }}-macosx_arm64
CIBW_BUILD_FRONTEND: build
CIBW_ENVIRONMENT: SSL_LIB_PATH="$(brew --prefix openssl@1.1)/lib/" CPATH="$(brew --prefix openssl@1.1)/include/" STATIC_SSL=1
CIBW_ARCHS: "arm64"

- name: Save macOS wheel
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: ${{ matrix.python }}-macosx_arm64.build
path: wheelhouse/*.whl

- name: Set final commit status
uses: myrotvorets/set-commit-status-action@v2.0.0
if: ${{ always() && github.event_name != 'push' && github.event_name != 'pull_request' }}
with:
status: ${{ job.status }}
sha: ${{ github.sha }}
context: "Build wheels (${{ matrix.python }}-macosx_arm64)"

# If we build the wheels on the self hosted M1 runners using setup-python, it creates universal wheels
# This did not happen when we used the Python choco installs
# We only want to produce arm64 specific wheels for macOS
macOS-m1-self-hosted:
if: ${{ inputs.run_tests }}
needs: macOS-m1
runs-on: [
self-hosted,
macOS,
Expand All @@ -312,95 +384,52 @@ jobs:
if: ${{ github.event_name != 'push' && github.event_name != 'pull_request' }}
with:
sha: ${{ github.sha }}
context: "Build wheels (${{ matrix.python-version[0] }}-macosx_arm64)"
context: "Test self-hosted (${{ matrix.python-version[0] }}-macosx_arm64)"

- uses: actions/checkout@v4
with:
submodules: recursive
ref: ${{ inputs.ref }}
fetch-depth: 0

# Update dependencies if needed
- name: Add brew to path
run: echo PATH=$PATH:/opt/homebrew/bin/ >> $GITHUB_ENV

- name: Install or upgrade Python
run: brew install python@${{ matrix.python-version[1] }}

- name: Install or upgrade OpenSSL 1.1
run: brew install openssl@1.1
- name: Download wheel
uses: actions/download-artifact@v4
with:
name: ${{ matrix.python-version[0] }}-macosx_arm64.build

- name: Set environment variables for building
run: |
openssl_path=$(brew --prefix openssl@1.1)
echo SSL_LIB_PATH="$openssl_path/lib/" >> $GITHUB_ENV
echo CPATH="$openssl_path/include/" >> $GITHUB_ENV
echo STATIC_SSL=1 >> $GITHUB_ENV
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version[1] }}

- name: Install pip build packages
run: python${{ matrix.python-version[1] }} -m pip install --break-system-packages --force-reinstall -r requirements.txt
- name: Install wheel
run: python3 -m pip install aerospike --force-reinstall --no-index --find-links=./

# Self-hosted runner only
# Need to be able to save Docker Hub credentials to keychain
- run: security unlock-keychain -p ${{ secrets.MAC_M1_SELF_HOSTED_RUNNER_PW }}
if: ${{ inputs.run_tests && inputs.use-server-rc }}
# The mac m1 self hosted runners use Docker Desktop which uses Keychain by default to store `docker login` credentials
# It's also required for pulling certain public images for some reason, like moby buildx
# There's currently no way to configure a different credential store (AFAIK), so we just need to make sure Keychain is unlocked
- name: Allow saving Docker Hub credentials using keychain and pulling moby buildx Docker image
run: security unlock-keychain -p ${{ secrets.MAC_M1_SELF_HOSTED_RUNNER_PW }}

- uses: ./.github/actions/run-ee-server
if: ${{ inputs.run_tests }}
with:
use-server-rc: ${{ inputs.use-server-rc }}
server-tag: ${{ inputs.server-tag }}
docker-hub-username: ${{ secrets.DOCKER_HUB_BOT_USERNAME }}
docker-hub-password: ${{ secrets.DOCKER_HUB_BOT_PW }}

- name: Set unoptimize flag
if: ${{ inputs.apply-no-optimizations }}
run: echo "UNOPTIMIZED=1" >> $GITHUB_ENV

- name: Set include dsym flag
if: ${{ inputs.include-debug-info-for-macos }}
run: echo "INCLUDE_DSYM=1" >> $GITHUB_ENV

- run: python${{ matrix.python-version[1] }} -m build

- name: Install delocate
run: python${{ matrix.python-version[1] }} -m pip install --break-system-packages --force-reinstall delocate -c ./requirements.txt
working-directory: .github/workflows

- run: delocate-wheel --require-archs "arm64" -w wheelhouse/ -v dist/*.whl
- run: python${{ matrix.python-version[1] }} -m pip install --break-system-packages --find-links=wheelhouse/ --no-index --force-reinstall aerospike

- run: python${{ matrix.python-version[1] }} -m pip install --break-system-packages --force-reinstall -r requirements.txt
if: ${{ inputs.run_tests }}
- run: python3 -m pip install -r requirements.txt
working-directory: test

- run: python${{ matrix.python-version[1] }} -m pytest new_tests/
if: ${{ inputs.run_tests }}
- run: python3 -m pytest new_tests/
working-directory: test

- run: python${{ matrix.python-version[1] }} -c "import aerospike"
if: ${{ !inputs.run_tests }}

- name: Save macOS wheel
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: ${{ matrix.python-version[0] }}-macosx_arm64.build
path: wheelhouse/*.whl

- name: Stop server
if: ${{ always() && inputs.run_tests }}
run: |
docker container stop aerospike
docker container prune -f

- name: Set final commit status
uses: myrotvorets/set-commit-status-action@v2.0.0
if: ${{ always() && github.event_name != 'push' && github.event_name != 'pull_request' }}
with:
sha: ${{ github.sha }}
status: ${{ job.status }}
context: "Build wheels (${{ matrix.python-version[0] }}-macosx_arm64)"
context: "Test self-hosted (${{ matrix.python-version[0] }}-macosx_arm64)"

windows-build:
strategy:
Expand Down Expand Up @@ -497,6 +526,7 @@ jobs:
- run: python3 -m pip install pytest -c requirements.txt
working-directory: test

# TODO: bug: inputs are not passed in. Just fix this in the refactoring PR
- uses: ./.github/actions/run-ee-server

- name: Connect to Docker container on remote machine with Docker daemon
Expand Down
Loading