diff --git a/.github/actions/testrpm/Dockerfile b/.github/actions/testrpm/Dockerfile new file mode 100644 index 00000000..71d63511 --- /dev/null +++ b/.github/actions/testrpm/Dockerfile @@ -0,0 +1,19 @@ +FROM opensuse/tumbleweed:latest + +# Update +RUN zypper patch -y + +# Install necessary packages +RUN zypper in -y \ + python311 python312 python313 + +WORKDIR /tmp/ + +# Copy necessary files to build a rpm package +COPY *.noarch.rpm ./ + +# Set up the entrypoint script +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/.github/actions/testrpm/action.yml b/.github/actions/testrpm/action.yml new file mode 100644 index 00000000..12e7ef7c --- /dev/null +++ b/.github/actions/testrpm/action.yml @@ -0,0 +1,6 @@ +name: "Test RPM package" +description: "Test RPM package on openSUSE Tumbleweed" + +runs: + using: "docker" + image: "Dockerfile" diff --git a/.github/actions/testrpm/entrypoint.sh b/.github/actions/testrpm/entrypoint.sh new file mode 100644 index 00000000..89bb2823 --- /dev/null +++ b/.github/actions/testrpm/entrypoint.sh @@ -0,0 +1,29 @@ +#! /bin/bash +set -e + +PRINT_VERSION='import bytecode; print("Bytecode version:", bytecode.__version__)' + +HELLO_WORLD=" +from bytecode import Instr, Bytecode + +bytecode = Bytecode([Instr(\"LOAD_GLOBAL\", (True, 'print')), + Instr(\"LOAD_CONST\", 'Hello World!'), + Instr(\"CALL\", 1), + Instr(\"POP_TOP\"), + Instr(\"LOAD_CONST\", None), + Instr(\"RETURN_VALUE\")]) +code = bytecode.to_code() +exec(code)" + +PY_VERSIONS=('python3.11' 'python3.12' 'python3.13') + +cd /tmp/ +rpm -ivh python3*.noarch.rpm + +# Test installation, print version, and run hello world +for py in ${PY_VERSIONS[@]} +do + echo "Test $($py --version)" + $py -c "$PRINT_VERSION" + $py -c "$HELLO_WORLD" && echo "" +done diff --git a/.github/workflows/rpmbuild.yml b/.github/workflows/rpmbuild.yml index f122acb9..76db47c0 100644 --- a/.github/workflows/rpmbuild.yml +++ b/.github/workflows/rpmbuild.yml @@ -21,5 +21,20 @@ jobs: - name: Upload RPM as artifact uses: actions/upload-artifact@v4 with: - name: python-bytecode-binary-rpm-${{ env.RELEASE_VERSION }} + name: python-bytecode-binary-rpm path: ${{ github.workspace }}/*.rpm + + test_rpm: + needs: build_rpm + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Download RPM artifact + uses: actions/download-artifact@v4 + with: + name: python-bytecode-binary-rpm + path: ./.github/actions/testrpm + + - name: Test RPM package + uses: ./.github/actions/testrpm