Skip to content

add generic cli options #448

add generic cli options

add generic cli options #448

Workflow file for this run

name: CI
on:
push:
pull_request:
release:
types: [released]
defaults:
run:
shell: pwsh
jobs:
package:
runs-on: ubuntu-latest
env:
PYTHONUTF8: 1
AEXPY_GZIP_IO: 1
GIT_COMMIT: ${{ github.sha }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: mamba-org/setup-micromamba@v1
with:
environment-name: main
create-args: >-
python=3.12
init-shell: >-
bash
powershell
cache-environment: true
post-cleanup: 'all'
- name: Inject Build Info
run: python ./scripts/inject_build.py
- name: Build
run: |
python -m pip install build
python -m build
- name: Upload package artifacts
uses: actions/upload-artifact@v4
with:
name: package
path: ./dist
- name: Prepare
run: |
python -m pip install ./dist/*.whl
aexpy --version
aexpy --help
mkdir -p ./cache
- name: Test Preprocess
run: |
aexpy -vvv preprocess -r -p generator-oj-problem@0.0.1 ./cache ./cache/distribution1.json.gz
aexpy -vvv preprocess -r -p generator-oj-problem@0.0.2 ./cache ./cache/distribution2.json.gz
- name: Test Extraction
run: |
aexpy -vvv extract ./cache/distribution1.json.gz ./cache/api1.json.gz
aexpy -vvv extract ./cache/distribution2.json.gz ./cache/api2.json.gz
- name: Test Extraction in Temp env
run: |
aexpy -vvv preprocess -r -p generator-oj-problem@0.0.1 -P 3.8 ./cache ./cache/distribution3.json.gz
aexpy -vvv extract ./cache/distribution3.json.gz ./cache/api3.json.gz --no-temp
aexpy -vvv extract ./cache/distribution3.json.gz ./cache/api4.json.gz --temp
- name: Test Extraction from other input mode
run: |
echo generator-oj-problem@0.0.1 | aexpy -vvv extract - ./cache/api5.json.gz -r
aexpy -vvv extract ./cache/generator_oj_problem-0.0.1-py3-none-any.whl ./cache/api6.json.gz -w
cd ./cache/generator_oj_problem-0.0.1-py3-none-any && zip -r - ./generator_oj_problem | aexpy -vvv extract - ../api7.json.gz -s
- name: Test Difference
run: |
aexpy -vvv diff ./cache/api1.json.gz ./cache/api2.json.gz ./cache/diff.json.gz
- name: Test Report
run: |
aexpy -vvv report ./cache/diff.json.gz ./cache/report.json.gz
- name: Test Image Runner
run: |
aexpy runimage -t stardustdl/aexpy:latest -- --version
aexpy runimage -v ./cache -t stardustdl/aexpy:latest -- view /data/report.json.gz
- name: Test Service Provider
env:
AEXPY_SERVICE: "./scripts/services.py"
run: |
echo "def getService(): return ServiceProvider()" | aexpy -vvv -s - view --help
aexpy -vvv view --help
aexpy -vvv extract ./cache/distribution1.json.gz ./cache/api8.json.gz
aexpy -vvv extract ./cache/distribution2.json.gz ./cache/api9.json.gz
aexpy -vvv diff ./cache/api8.json.gz ./cache/api9.json.gz ./cache/diff3.json.gz
aexpy -vvv report ./cache/diff3.json.gz ./cache/report3.json.gz
- name: Test Stats
run: |
python -m aexpy stat ./cache/*.json.gz ./cache/stats.json.gz
- name: Test View
shell: bash
run: |
cd cache && find . -maxdepth 1 -type f -name "*.json.gz" -exec micromamba run -n main aexpy -vvv view {} \;
- name: Upload results
uses: actions/upload-artifact@v4
with:
name: package-cache
path: ./cache
- name: Self bootstrapping
run: |
mkdir -p self/${{ github.ref_name }}
aexpy -vvv --no-gzip extract ./dist/*.whl ./self/${{ github.ref_name }}.json -w
- name: Upload self analyse results
uses: actions/upload-artifact@v4
with:
name: self-results
path: ./self
image:
runs-on: ubuntu-latest
env:
PYTHONUTF8: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Inject Build Info
run: python ./scripts/inject_build.py
- name: Build
run: |
docker build -t aexpy/aexpy .
- name: Prepare
run: |
docker run aexpy/aexpy --version
docker run aexpy/aexpy --help
mkdir -p ./cache
- name: Test Service Provider
run: |
echo "def getService(): return ServiceProvider()" | docker run -i aexpy/aexpy -vvv -s - view --help
- name: Test Preprocess
run: |
docker run -v ${{ github.workspace }}/cache:/data -u "$(id -u):$(id -g)" aexpy/aexpy -vvv preprocess -r -p generator-oj-problem@0.0.1 /data /data/distribution1.json
docker run -v ${{ github.workspace }}/cache:/data -u "$(id -u):$(id -g)" aexpy/aexpy -vvv preprocess -r -p generator-oj-problem@0.0.2 /data /data/distribution2.json
- name: Test Extraction
run: |
docker run -v ${{ github.workspace }}/cache:/data -u "$(id -u):$(id -g)" aexpy/aexpy -vvv extract /data/distribution1.json /data/api1.json
docker run -v ${{ github.workspace }}/cache:/data -u "$(id -u):$(id -g)" aexpy/aexpy -vvv extract /data/distribution2.json /data/api2.json
- name: Test Extraction in Env
run: |
docker run -v ${{ github.workspace }}/cache:/data -u "$(id -u):$(id -g)" aexpy/aexpy -vvv preprocess -r -p generator-oj-problem@0.0.1 -P 3.8 /data /data/distribution3.json
docker run -v ${{ github.workspace }}/cache:/data -u "$(id -u):$(id -g)" aexpy/aexpy -vvv extract /data/distribution3.json /data/api3.json --temp
docker run -v ${{ github.workspace }}/cache:/data -u "$(id -u):$(id -g)" aexpy/aexpy -vvv extract /data/distribution3.json /data/api4.json --no-temp
- name: Test Extraction from other input mode
run: |
echo generator-oj-problem@0.0.1 | docker run -i aexpy/aexpy -vvv extract - - -r > ./cache/api5.json
sudo cat ./cache/generator_oj_problem-0.0.1-py3-none-any.whl | docker run -i aexpy/aexpy -vvv extract - - -w --wheel-name generator_oj_problem-0.0.1-py3-none-any > ./cache/api6.json
cd ./cache/generator_oj_problem-0.0.1-py3-none-any && sudo zip -r - ./generator_oj_problem | docker run -i aexpy/aexpy -vvv extract - - -s > ../api7.json
- name: Test Difference
run: |
docker run -v ${{ github.workspace }}/cache:/data -u "$(id -u):$(id -g)" aexpy/aexpy -vvv diff /data/api1.json /data/api2.json /data/diff.json
echo "," | sudo cat ./cache/api1.json - ./cache/api2.json | docker run -i aexpy/aexpy -vvv diff - - - > ./cache/diff2.json
- name: Test Report
run: |
docker run -v ${{ github.workspace }}/cache:/data -u "$(id -u):$(id -g)" aexpy/aexpy -vvv report /data/diff.json /data/report.json
- name: Test View
shell: bash
run: |
cd cache && sudo find . -maxdepth 1 -type f -name "*.json" -exec docker run -v ${{ github.workspace }}/cache:/data -u "$(id -u):$(id -g)" aexpy/aexpy -vvv view /data/{} \;
- name: Upload results
uses: actions/upload-artifact@v4
with:
name: image-cache
path: ./cache
web:
runs-on: ubuntu-latest
env:
PYTHONUTF8: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Prepare Vite
run: |
cd ./src/web && npm install
- name: Set Build Env
shell: bash
run: |
echo -e "VITE_NOSERVER=1\nVITE_COMMIT_ID=${{ github.sha }}\nVITE_BUILD_DATE=$(date -Iseconds)" > ./src/web/.env
- name: Build
run: |
cd ./src/web && npm run build
- name: Add track tag
run: |
python ./scripts/add_web_track.py
- name: Upload results
uses: actions/upload-artifact@v4
with:
name: web-dist
path: ./src/web/dist
docs:
runs-on: ubuntu-latest
env:
PYTHONUTF8: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup paperead
run: pip install paperead
- name: Generate documents
run: |
cd docs
paperead build
- name: Add track tag
run: |
python ./scripts/add_web_track.py
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: docs
path: ./docs/dist
deploy:
if: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) && github.event_name == 'push' || github.event_name == 'release' }}
needs: [image, docs, package, web]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
deploy-apis:
needs: [deploy]
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
env:
PYTHONUTF8: 1
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Checkout pages
continue-on-error: true
run: |
git fetch origin gh-pages
git worktree add ./dist gh-pages
- name: Download self artifacts
uses: actions/download-artifact@v4
with:
name: self-results
path: ./self
- name: Copy data
shell: bash
run: |
mkdir dist || echo "exists"
cp -r ./self/* ./dist
- name: Upload API artifacts
uses: actions/upload-artifact@v4
with:
name: apis
path: ./dist
- name: Deploy GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.PA_TOKEN }}
branch: gh-pages
folder: ./dist
deploy-web:
needs: [deploy]
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
env:
PYTHONUTF8: 1
steps:
- name: Download docs artifacts
uses: actions/download-artifact@v4
with:
name: docs
path: ./docs-dist
- name: Add redirects
shell: bash
run: |
echo -e "/* /index.html 200" > ./docs-dist/_redirects
- name: Deploy docs to netlify
uses: netlify/actions/cli@master
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_DOC_SITE_ID }}
with:
args: deploy --dir=./docs-dist --prod
secrets: '["NETLIFY_AUTH_TOKEN", "NETLIFY_SITE_ID"]'
- name: Download app artifacts
uses: actions/download-artifact@v4
with:
name: web-dist
path: ./web-dist
- name: Add redirects
shell: bash
run: |
echo -e "/data https://aexpy-docs.netlify.app/data 301\n/change-spec https://aexpy-docs.netlify.app/change-spec 301\n/* /index.html 200" > ./web-dist/_redirects
- name: Deploy docs to netlify
uses: netlify/actions/cli@master
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_APP_SITE_ID }}
with:
args: deploy --dir=./web-dist --prod
secrets: '["NETLIFY_AUTH_TOKEN", "NETLIFY_SITE_ID"]'
deploy-package:
needs: [deploy]
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
steps:
- name: Download package artifacts
uses: actions/download-artifact@v4
with:
name: package
path: ./dist
- name: Deploy packages
env:
TWINE_USERNAME: '__token__'
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python -m pip install --upgrade twine
python -m twine upload --skip-existing --repository pypi "dist/*"
deploy-image:
needs: [deploy]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Image Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: stardustdl/aexpy
- name: Inject Build Info
run: python ./scripts/inject_build.py
- name: Deploy image
uses: docker/build-push-action@v5
with:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
context: .