Skip to content

Commit

Permalink
ci: verify extra in the real docker build environment
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed Nov 13, 2024
1 parent beb1c9d commit f12a4ac
Showing 1 changed file with 46 additions and 7 deletions.
53 changes: 46 additions & 7 deletions .github/workflows/verify_extra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,27 @@ on:

jobs:
verify:
name: Verify python:${{ matrix.python }}${{ matrix.slim == 'true' && '-slim' || '' }}
runs-on: ubuntu-latest
strategy:
matrix:
python: ['3.11', '3.12', '3.13'] # last 3 minor versions
slim: ['true', 'false']

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '${{ matrix.python }}'

- name: Verify Installability
- name: Prepare requirements and Dockerfile
run: |
python3 -m pip install -U pip
set -eux
mkdir extra_check
cp src/requirements_extra.txt extra_check/requirements_extra.txt
cd extra_check
python3 -m pip install -U pip
output=$(pip3 install --dry-run --no-deps -I --report - --quiet mcdreforged 2>/dev/null)
mcdr_version=$(echo -E "$output" | jq '.install[0].metadata.version' -r)
if [ -z $mcdr_version ]; then
Expand All @@ -31,11 +37,44 @@ jobs:
exit 1
fi
echo "Latest MCDR version: $mcdr_version"
echo "mcdreforged==$mcdr_version" >> src/requirements_extra.txt
pip3 install -r src/requirements_extra.txt
echo "mcdreforged==$mcdr_version" >> ./requirements_extra.txt
cat ./requirements_extra.txt
echo "# Installation Summary (python ${{matrix.python}})" >> $GITHUB_STEP_SUMMARY
cat <<EOF > Dockerfile
FROM python:${{ matrix.python }}${{ matrix.slim == 'true' && '-slim' || '' }}
COPY ./requirements_extra.txt /
RUN <<EOT
set -eux
export PIP_ROOT_USER_ACTION=ignore
python3 -m pip install -U pip
pip3 install -r /requirements_extra.txt
pip3 cache purge && rm -rf ~/.cache/
EOT
EOF
cat Dockerfile
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build check
id: build
uses: docker/build-push-action@v5
with:
platforms: linux/amd64
file: extra_check/Dockerfile
context: extra_check
push: false
tags: mcdreforged/ci-extra-verification:latest

- name: pip freeze
uses: addnab/docker-run-action@v3
with:
image: mcdreforged/ci-extra-verification:latest
options: -v ./freeze_out:/freeze_out
run: pip3 freeze > /freeze_out/freeze.txt

- name: Report
run: |
echo "# Installation Summary (python ${{ matrix.python }}, slime ${{ matrix.slim }})" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
pip3 freeze >> $GITHUB_STEP_SUMMARY
cat ./freeze_out/freeze.txt >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY

0 comments on commit f12a4ac

Please sign in to comment.