diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml deleted file mode 100644 index 862bb21..0000000 --- a/.azure-pipelines/azure-pipelines.yml +++ /dev/null @@ -1,19 +0,0 @@ -trigger: - branches: - include: - - '*' - tags: - include: - - '*' - -pool: - vmImage: 'ubuntu-latest' - -variables: - - group: codecov - - group: pypi - -stages: - - template: stage-lint.yml - - template: stage-test.yml - - template: stage-publish.yml diff --git a/.azure-pipelines/stage-lint.yml b/.azure-pipelines/stage-lint.yml deleted file mode 100644 index c5ff3b8..0000000 --- a/.azure-pipelines/stage-lint.yml +++ /dev/null @@ -1,29 +0,0 @@ -stages: - - stage: lint - displayName: 'Lint' - - jobs: - - job: 'lint' - pool: - vmImage: 'ubuntu-latest' - - steps: - - checkout: self - clean: true - - - task: UsePythonVersion@0 - inputs: - versionSpec: '3.10' - architecture: 'x64' - - - script: | - pip install poetry - displayName: 'Install poetry' - - - script: | - poetry install - displayName: 'Install deps' - - - script: | - make lint - displayName: 'Run linters' diff --git a/.azure-pipelines/stage-publish.yml b/.azure-pipelines/stage-publish.yml deleted file mode 100644 index 8868682..0000000 --- a/.azure-pipelines/stage-publish.yml +++ /dev/null @@ -1,21 +0,0 @@ -stages: - - stage: publish - displayName: 'Publish' - condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) - - jobs: - - job: 'Publish' - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '3.10' - architecture: 'x64' - - - script: | - pip install poetry - displayName: 'Install poetry' - - script: | - poetry publish --build - displayName: 'Publish to PyPI' - env: - POETRY_PYPI_TOKEN_PYPI: $(PYPI_TOKEN) diff --git a/.azure-pipelines/stage-test.yml b/.azure-pipelines/stage-test.yml deleted file mode 100644 index 4634e1e..0000000 --- a/.azure-pipelines/stage-test.yml +++ /dev/null @@ -1,59 +0,0 @@ -stages: - - stage: test - displayName: 'Test' - - jobs: - - job: 'Test' - pool: - vmImage: 'ubuntu-latest' - variables: - PYTHONPATH: $(Build.SourcesDirectory) - strategy: - maxParallel: 2 - matrix: - Python_310: - python.version: '3.10' - Python_311: - python.version: '3.11' - - steps: - - checkout: self - clean: true - - - task: UsePythonVersion@0 - inputs: - versionSpec: '$(python.version)' - architecture: 'x64' - - - script: | - pip install poetry - displayName: 'Install poetry' - - - script: | - poetry install - displayName: 'Install deps' - - - script: | - make test - displayName: 'Run tests' - - - task: PublishTestResults@2 - inputs: - testResultsFiles: 'junit.xml' - testRunTitle: 'Publish test results for Python $(python.version)' - condition: succeededOrFailed() - - - task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: 'cobertura' - summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' - reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' - pathToSources: 'tg_odesli_bot' - condition: succeededOrFailed() - - - script: | - bash <(curl -s https://codecov.io/bash) - displayName: 'Upload codecov' - env: - CODECOV_TOKEN: $(CODECOV_TOKEN) - condition: always() diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..95d5a4d --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,84 @@ +name: Lint and test + +on: + push: + branches: + - '*' + tags: + - '*' + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: 3.11 + + - name: Install poetry + run: pip install poetry + + - name: Install dependencies + run: poetry install --with main,dev + + - name: Run linters + run: make lint + + test: + strategy: + matrix: + python-version: ['3.10', '3.11'] + fail-fast: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install poetry + run: pip install poetry + + - name: Install dependencies + run: poetry install --with main,dev + + - name: Run tests + run: make test + + publish: + runs-on: ubuntu-latest + if: github.ref_type == 'tag' + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: 3.11 + + - name: Install poetry + run: pip install poetry + + - name: Publish to PyPI + run: poetry publish --build + env: + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} + + - name: Login to DockerHub + run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin + + - name: Build and push Docker image + run: | + docker build -t ${{ secrets.DOCKER_USERNAME }}/tg-odesli-bot:${{ github.ref }} . + docker push ${{ secrets.DOCKER_USERNAME }}/tg-odesli-bot:${{ github.ref }}