From afce3b95f1e6b2d7dd5680155c759d48f7bcde81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Voituret?= Date: Wed, 8 Jul 2020 14:59:50 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20setup=20Github=20actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker.yml | 78 ++++++++++++++++++++++++++++++++++++ .github/workflows/pypi.yml | 27 +++++++++++++ .github/workflows/pytest.yml | 23 +++++++++++ Makefile | 2 - 4 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/docker.yml create mode 100644 .github/workflows/pypi.yml create mode 100644 .github/workflows/pytest.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..16cd8ab --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,78 @@ +name: docker +on: + - workflow_dispatch +jobs: + build-test-push: + runs-on: ubuntu-latest + strategy: + matrix: + platform: [cpu, gpu] + distribution: [3.6, 3.7, conda] + model: [modelless, 2stems, 4stems, 5stems] + fail-fast: true + steps: + - uses: actions/checkout@v2 + # ---------------------------------------------------------------------- + # Note: base image building and env setup. + - name: Setup Python distribution + run: | + echo "::set-env name=base::python:${{ matrix.distribution }}" + echo "::set-env name=tag::${{ matrix.distribution }}" + echo "::set-env name=file::spleeter" + - if: ${{ matrix.distribution }} == 'conda' + name: Build Conda base image + run: | + docker build -t python:conda -f docker/conda.dockerfile . + echo "::set-env name=file::spleeter-conda" + - if: ${{ matrix.platform }} == 'gpu' + name: Build CUDA base image + run: | + docker build \ + --build-arg BASE=python:${{ matrix.distribution }} + -t cuda:${{ matrix.distribution }} \ + -f docker/cuda-10-0.dockerfile . + echo "::set-env name=base::cuda:${{ matrix.distribution }}" + echo "::set-env name=tag::${{ matrix.distribution }}-gpu" + # ---------------------------------------------------------------------- + # Note: image building. + - name: Build researchdeezer/spleeter:${{ env.tag }} image + run: | + docker build \ + --build-arg BASE=${{ env.base }} \ + -t researchdeezer/spleeter:${{ env.tag }} \ + -f docker/${{ env.file }}.dockerfile . + echo "::set-env name=modelargs::" + - if: ${{ matrix.model }} != 'modelless' + name: Build researchdeezer/spleeter:${{ env.tag }}-${{ matrix.model }} image + run: | + docker build \ + --build-arg BASE=researchdeezer/spleeter:${{ env.tag }} \ + --build-arg MODEL=${{ matrix.model }} \ + -t researchdeezer/spleeter:${{ env.tag }}-${{ matrix.model }} \ + -f docker/spleeter-model.dockerfile . + echo "::set-env name=tag::${{ env.tag }}-${{ matrix.model }}" + echo "::set-env name=modelarg::-p spleeter:${{ matrix.model }}" + # ---------------------------------------------------------------------- + # Note: image testing. + - name: Test researchdeezer/spleeter:${{ env.tag }} image + run: | + docker run \ + -v $(pwd):/runtime \ + researchdeezer/spleeter:${{ env.tag }} \ + separate -i /runtime/audio_example.mp3 -o /tmp \${{ env.modelarg }} + # ---------------------------------------------------------------------- + # Note: image deploy. + - name: Docker login + run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin + - name: Push researchdeezer/spleeter:${{ env.tag }} image + run: docker push researchdeezer/spleeter:${{ env.tag }} + - if: ${{ env.tag }} == 'spleeter:3.7' + name: Push researchdeezer/spleeter:latest image + run: | + docker tag researchdeezer/spleeter:3.7 researchdeezer/spleeter:latest + docker push researchdeezer/spleeter:latest + - if: ${{ env.tag }} == 'spleeter:3.7-gpu' + name: Push researchdeezer/spleeter:gpu image + run: | + docker tag researchdeezer/spleeter:3.7-gpu researchdeezer/spleeter:gpu + docker push researchdeezer/spleeter:gpu diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 0000000..8f3e457 --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,27 @@ +name: pypi +on: + pull_request: + types: + - closed + branches: + - master +env: + TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} + TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} +jobs: + deploy-cpu: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Package sdist + run: make build + - name: Deploy to pypi + run: make deploy + deploy-gpu: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Package sdist + run: make build-gpu + - name: Deploy to pypi + run: make deploy \ No newline at end of file diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 0000000..41299e7 --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,23 @@ +name: pytest +on: + - push + - pull_request +jobs: + tests: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + apt-get update && apt-get install -y ffmpeg + pip install pytest==5.4.3 pytest-xdist==1.32.0 pytest-forked==1.1.3 musdb museval + python setup.py install + - name: Test with pytest + run: make test \ No newline at end of file diff --git a/Makefile b/Makefile index 740d6cd..a67a64d 100644 --- a/Makefile +++ b/Makefile @@ -33,8 +33,6 @@ test: $(PYTEST_CMD) tests/test_ffmpeg_adapter.py $(PYTEST_CMD) tests/test_github_model_provider.py $(PYTEST_CMD) --boxed tests/test_separator.py - - deploy: pip install twine