From ad178d694ecb0acab1c105f63661ccce4bc100b8 Mon Sep 17 00:00:00 2001 From: b-long <(none)> Date: Thu, 18 Jul 2024 21:08:05 -0400 Subject: [PATCH] Fix build --- .github/workflows/build-golang-macos.yaml | 142 ------------ .github/workflows/build-golang-ubuntu.yaml | 144 ------------ .github/workflows/build-python.yaml | 45 ---- .github/workflows/multiplatform-build.yaml | 253 +++++++++++++++++++++ 4 files changed, 253 insertions(+), 331 deletions(-) delete mode 100644 .github/workflows/build-golang-macos.yaml delete mode 100644 .github/workflows/build-golang-ubuntu.yaml delete mode 100644 .github/workflows/build-python.yaml create mode 100644 .github/workflows/multiplatform-build.yaml diff --git a/.github/workflows/build-golang-macos.yaml b/.github/workflows/build-golang-macos.yaml deleted file mode 100644 index ecdd4df..0000000 --- a/.github/workflows/build-golang-macos.yaml +++ /dev/null @@ -1,142 +0,0 @@ ---- -name: macOS -- Build Python wheel using golang's gopy - -on: - push: - branches: - - main - -defaults: - run: - shell: bash - -jobs: - call-lint: - uses: ./.github/workflows/lint-on-macos.yaml - - build: - runs-on: macos-13 - permissions: - contents: write - - strategy: - fail-fast: true - matrix: - go-version: [1.22.x] - # go-version: [ '1.19', '1.20', '1.22.x' ] - - steps: - - uses: actions/checkout@v4 - - - name: Setup Docker on macOS using Colima, Lima-VM, and Homebrew - uses: douglascamata/setup-docker-macos-action@v1-alpha - with: - upgrade-qemu: true - - - - name: Verify docker Installation - run: | - docker --version - docker ps - - - name: Setup vagrant - run: | - brew install vagrant - vagrant --version - - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: ${{ matrix.go-version }} - cache-dependency-path: go.sum - - name: Install dependencies - run: go get . - - name: Test with Go - run: go test - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - pip install poetry - - # Look for go/bin (skip, we know it exists) - echo '$HOME/' - ls -la "$HOME/" - - echo '$HOME/.local/' - ls -la "$HOME/.local/" - - echo '$HOME/go/' - ls -la "$HOME/go/" - - - name: Add Go bin directory to PATH - run: echo "export PATH=$PATH:~/.local/go/bin" >> $GITHUB_ENV - - # FIXME: Add more caching - - name: Add gopy dependencies and build wheel - run: | - # Since we don't have our wheel build / install configured yet we use '--no-root' - poetry install --no-root - - source .venv/bin/activate - - # Add Go bin directory to PATH - echo "export PATH=$PATH:~/.local/go/bin" >> $GITHUB_ENV - - go install golang.org/x/tools/cmd/goimports@latest - - go install github.com/go-python/gopy@latest - - poetry run pip install --upgrade setuptools wheel - - gopy build --output=ohpygossh -vm=python3 . - - poetry run python3 setup.py bdist_wheel - - - name: Test Python wheel - run: | - # Test wheel installation - pip install dist/ohpygossh-0.0.7-py3-none-any.whl - - # Test wheel functionality - python3 validate_ohpygossh.py - - # release: - # needs: build - # runs-on: macos-latest - # if: github.ref == 'refs/heads/main' - # permissions: - # contents: write - # steps: - # - uses: actions/checkout@v4 - - - name: Store version - run: | - pip install poetry - - PROJECT_VESION=$(poetry version -s) - echo "PROJECT_VESION=$PROJECT_VESION" >> $GITHUB_ENV - - - name: Install twine - run: pip install twine - - - name: Upload to PyPI - env: - TWINE_UPLOAD_URL: https://upload.pypi.org/legacy/ - PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} - PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - twine upload --password "$PYPI_PASSWORD" --user "$PYPI_USERNAME" --repository-url "$TWINE_UPLOAD_URL" dist/* - - - uses: ncipollo/release-action@v1 - with: - artifacts: | - README.md, - dist/*.whl - body: OhPyGoSSH version ${{ env.PROJECT_VESION }} - # tag: "dev-${{ github.job }}-${{ env.PROJECT_VESION }}" - tag: v${{ env.PROJECT_VESION }} diff --git a/.github/workflows/build-golang-ubuntu.yaml b/.github/workflows/build-golang-ubuntu.yaml deleted file mode 100644 index 3207aa8..0000000 --- a/.github/workflows/build-golang-ubuntu.yaml +++ /dev/null @@ -1,144 +0,0 @@ ---- -name: Ubuntu -- Build Python wheel using golang's gopy - -on: [push] - -jobs: - call-lint: - uses: ./.github/workflows/lint-on-ubuntu.yaml - - build: - runs-on: ubuntu-latest - permissions: - contents: write - - strategy: - fail-fast: true - matrix: - go-version: [1.22.x] - # go-version: [ '1.19', '1.20', '1.22.x' ] - - steps: - - uses: actions/checkout@v4 - - - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: ${{ matrix.go-version }} - cache-dependency-path: go.sum - - name: Install dependencies - run: go get . - - name: Test with Go - run: go test - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - pip install poetry - - # Look for go/bin (skip, we know it exists) - echo '$HOME/' - ls -la "$HOME/" - - echo '$HOME/.local/' - ls -la "$HOME/.local/" - - echo '$HOME/go/' - ls -la "$HOME/go/" - - - name: Add Go bin directory to PATH - run: echo "export PATH=$PATH:~/.local/go/bin" >> $GITHUB_ENV - - # FIXME: Add more caching - - name: Add gopy dependencies and build wheel - run: | - # Since we don't have our wheel build / install configured yet we use '--no-root' - poetry install --no-root - - source .venv/bin/activate - - # Add Go bin directory to PATH - echo "export PATH=$PATH:~/.local/go/bin" >> $GITHUB_ENV - - go install golang.org/x/tools/cmd/goimports@latest - - go install github.com/go-python/gopy@latest - - poetry run pip install --upgrade setuptools wheel - - gopy build --output=ohpygossh -vm=python3 . - - poetry run python3 setup.py bdist_wheel - - # TODO: Can this be a distinct job? - # exercise-ssh: - # needs: build - - # runs-on: ubuntu-latest - - # steps: - # - uses: actions/checkout@v4 - - - name: Check existing workspace content - run: | - ls -la - ls -la dist/ - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Install Vagrant - run: sudo apt-get update && sudo apt-get install -y vagrant - - - name: Create Vagrantfile - run: | - cat << EOF > Vagrantfile - Vagrant.configure("2") do |config| - config.vm.provider "docker" do |d| - d.image = "ubuntu" - d.cmd = [ "/bin/bash", "-c", "echo 'Hello world'" ] - d.remains_running = false - end - end - EOF - - - name: Run vagrant up - run: vagrant up --provider=docker - - - name: Launch the Docker/Vagrant test machine - run: | - # Change directory - cd ssh-servers/docker-in-vagrant - - # List content in the directory - ls -la - - # Launch machine - vagrant up --provider=docker - - # Connect to it with SSH - vagrant ssh -c "echo 'Hello Ubuntu'" - - - name: Test Python wheel - run: | - # Test wheel installation - pip install dist/ohpygossh-0.0.7-py3-none-any.whl - - # DISABLED: Need to figure out Ubuntu nested VM - # Test wheel functionality - # python3 validate_ohpygossh.py - - # DISABLED: Only release from macOS build - # - uses: ncipollo/release-action@v1 - # with: - # artifacts: | - # README.md, - # dist/*.whl - # body: OhPyGoSSH version ${{ github.sha }} - # # tag: "dev-${{ github.job }}-${{ github.sha }}" - # tag: dev-${{ github.run_number }} diff --git a/.github/workflows/build-python.yaml b/.github/workflows/build-python.yaml deleted file mode 100644 index efd89ca..0000000 --- a/.github/workflows/build-python.yaml +++ /dev/null @@ -1,45 +0,0 @@ ---- -name: Build Python package(s) - -on: - push: - branches: - - disabled - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - matrix: - go-version: [1.22.x] - # go-version: [ '1.19', '1.20', '1.22.x' ] - - steps: - - uses: actions/checkout@v4 - # - name: Setup Go - # uses: actions/setup-go@v4 - # with: - # go-version: ${{ matrix.go-version }} - # cache-dependency-path: go.sum - # - name: Install dependencies - # run: go get . - # - name: Test with Go - # run: go test - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - name: Install dependencies - run: | - pip install poetry - - name: Invoke pylint with all dependencies - run: | - # Since we don't have our wheel build / install configured yet we use '--no-root' - poetry install --no-root - - # poetry install - - # Bring this back later - # poetry run pytest tests/ diff --git a/.github/workflows/multiplatform-build.yaml b/.github/workflows/multiplatform-build.yaml new file mode 100644 index 0000000..4d33937 --- /dev/null +++ b/.github/workflows/multiplatform-build.yaml @@ -0,0 +1,253 @@ +--- +name: Multiplatform -- Build Python wheel using golang's gopy + +# Based on https://github.com/tuananh/py-event-ruler/blob/0129d15e17d0023863a4d0e0e25e5256988b5c5b/.github/workflows/publish.yml + +on: + push: + branches: + - main + +defaults: + run: + shell: bash + +jobs: + call-lint: + uses: ./.github/workflows/lint-on-macos.yaml + + build_macos: + permissions: + contents: write + + strategy: + fail-fast: true + matrix: + os_version: [ 13 ] + go-version: [ 1.22.x ] + python3_version: [ 11 ] + # go-version: [ '1.19', '1.20', '1.22.x' ] + + runs-on: macos-${{ matrix.os_version }} + steps: + - uses: actions/checkout@v4 + + - name: Setup Docker on macOS using Colima, Lima-VM, and Homebrew + uses: douglascamata/setup-docker-macos-action@v1-alpha + + + - name: Verify docker Installation + run: | + docker --version + docker ps + + - name: Setup vagrant + run: | + brew install vagrant + vagrant --version + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + cache-dependency-path: go.sum + - name: Install dependencies + run: go get . + - name: Test with Go + run: go test + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Install dependencies + run: | + pip install poetry + + # Look for go/bin (skip, we know it exists) + echo '$HOME/' + ls -la "$HOME/" + + echo '$HOME/go/' + ls -la "$HOME/go/" + + - name: Add Go bin directory to PATH + run: echo "export PATH=$PATH:~/.local/go/bin" >> $GITHUB_ENV + + # FIXME: Add more caching + - name: Add gopy dependencies and build wheel + run: | + # Since we don't have our wheel build / install configured yet we use '--no-root' + poetry install --no-root + + source .venv/bin/activate + + # Add Go bin directory to PATH + echo "export PATH=$PATH:~/.local/go/bin" >> $GITHUB_ENV + + go install golang.org/x/tools/cmd/goimports@latest + + go install github.com/go-python/gopy@latest + + poetry run pip install --upgrade setuptools wheel + + gopy build --output=ohpygossh -vm=python3 . + + poetry run python3 setup.py bdist_wheel + + - name: Test Python wheel + run: | + # Test wheel installation + pip install dist/ohpygossh-0.0.7-py3-none-any.whl + + # Test wheel functionality + python3 validate_ohpygossh.py + + # Name properly + mv dist/ohpygossh-0.0.7-py3-none-any.whl dist/ohpygossh-0.0.7-none-any-macosx_11_0_x86_64.whl + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + # name: wheels-macos${{ matrix.os_version }}-py3${{ matrix.python3_version }}-${{ matrix.arch_cibw_go[0] }} + name: wheels-macos${{ matrix.os_version }}-py3${{ matrix.python3_version }}-x86_64 + path: ./dist/*.whl + + build_linux_x86_64: + runs-on: ubuntu-latest + permissions: + contents: write + + strategy: + fail-fast: true + matrix: + go-version: [1.22.x] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Install Vagrant + run: sudo apt-get update && sudo apt-get install -y vagrant + + - name: Verify docker and vagrant installation + run: | + docker --version + docker ps + vagrant --version + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + cache-dependency-path: go.sum + + - name: Install dependencies + run: go get . + - name: Test with Go + run: go test + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Install dependencies + run: | + pip install poetry + + # Look for go/bin (skip, we know it exists) + echo '$HOME/' + ls -la "$HOME/" + + echo '$HOME/go/' + ls -la "$HOME/go/" + + - name: Add Go bin directory to PATH + run: echo "export PATH=$PATH:~/.local/go/bin" >> $GITHUB_ENV + + # FIXME: Add more caching + - name: Add gopy dependencies and build wheel + run: | + # Since we don't have our wheel build / install configured yet we use '--no-root' + poetry install --no-root + + source .venv/bin/activate + + # Add Go bin directory to PATH + echo "export PATH=$PATH:~/.local/go/bin" >> $GITHUB_ENV + + go install golang.org/x/tools/cmd/goimports@latest + + go install github.com/go-python/gopy@latest + + poetry run pip install --upgrade setuptools wheel + + gopy build --output=ohpygossh -vm=python3 . + + poetry run python3 setup.py bdist_wheel + + - name: Test Python wheel + run: | + # Test wheel installation + pip install dist/ohpygossh-0.0.7-py3-none-any.whl + + # Test wheel functionality + python3 validate_ohpygossh.py + + # Name properly + mv dist/ohpygossh-0.0.7-py3-none-any.whl dist/ohpygossh-0.0.7-none-any-manylinux2014_x86_64.whl + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: wheels-linux-amd64 + path: ./dist/*.whl + + release: + permissions: + contents: write + needs: [build_macos, build_linux_x86_64] + runs-on: ubuntu-latest + # if: github.ref == 'refs/heads/main' + + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + + - name: Collect all wheels + run: | + # ls -R + mkdir dist + for f in $(find . -type f -name '*.whl'); do mv ${f} dist; done; + ls -R dist + + - name: Store version + run: | + pip install poetry + + PROJECT_VESION=$(poetry version -s) + echo "PROJECT_VESION=$PROJECT_VESION" >> $GITHUB_ENV + + - name: Install twine + run: pip install twine + + - name: Upload to PyPI + env: + TWINE_UPLOAD_URL: https://upload.pypi.org/legacy/ + PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + twine upload --password "$PYPI_PASSWORD" --user "$PYPI_USERNAME" --repository-url "$TWINE_UPLOAD_URL" dist/* + + - uses: ncipollo/release-action@v1 + with: + artifacts: | + README.md, + dist/*.whl + body: OhPyGoSSH version ${{ env.PROJECT_VESION }} + # tag: "dev-${{ github.job }}-${{ env.PROJECT_VESION }}" + tag: v${{ env.PROJECT_VESION }}