diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml deleted file mode 100644 index 098fce2..0000000 --- a/.github/workflows/analysis.yml +++ /dev/null @@ -1,68 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - pull_request: - # The branches below must be a subset of the branches above - branches: [ master ] - -jobs: - codeql-analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'python' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] - # Learn more: - # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - queries: security-and-quality - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml deleted file mode 100644 index 79f73e0..0000000 --- a/.github/workflows/docker-image.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: "Build Docker image" - -on: - release: - types: - - published - -defaults: - run: - shell: bash - -jobs: - build-docker: - name: "đŸŗ Build and publish Docker image" - runs-on: ubuntu-latest - - steps: - - name: "Checkout repository" - uses: actions/checkout@v2 - - - name: "❓ Find the release semantic version" - id: semver - uses: Steffo99/actions-semver@v0.3.5 - with: - string: ${{ github.event.release.tag_name }} - - - name: "🔨 Setup Buildx" - uses: docker/setup-buildx-action@v1 - - - name: "🔑 Login to GitHub Containers" - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: RYGhub - password: ${{ secrets.GITHUB_TOKEN }} - - - name: "🏗 Build and push the Docker image" - uses: docker/build-push-action@v3.2.0 - with: - tags: >- - ghcr.io/steffo99/greed:${{ steps.semver.outputs.precedence }}, - ghcr.io/steffo99/greed:${{ steps.semver.outputs.core }}, - ghcr.io/steffo99/greed:${{ steps.semver.outputs.pair }}, - ghcr.io/steffo99/greed:${{ steps.semver.outputs.major }}, - ghcr.io/steffo99/greed:latest - platforms: >- - linux/amd64 - push: true diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml new file mode 100644 index 0000000..7948574 --- /dev/null +++ b/.github/workflows/quality.yml @@ -0,0 +1,15 @@ +name: "Periodic quality and security analysis" + +on: + # Every monday at 09:48 UTC + schedule: + - cron: "48 9 * * 1" + workflow_dispatch: + +jobs: + codeql: + uses: Steffo99/.github/.github/workflows/quality-python-codeql.yml@main + permissions: + actions: read + contents: read + security-events: write diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8f167e7..7b7ab39 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,52 +1,16 @@ -name: "Build Docker image" +name: "Release new version" on: - push: + # Creation of a new tag starting with v + push: tags: - "v*" -defaults: - run: - shell: bash - jobs: - build-docker: - name: "đŸŗ Build and publish Docker image" - runs-on: ubuntu-latest - - steps: - - name: "Checkout repository" - uses: actions/checkout@v2 - - - name: "❓ Find the release semantic version" - id: semver - uses: Steffo99/actions-semver@v0.3.5 - with: - string: ${{ github.ref_name }} - - - name: "🔨 Setup Buildx" - uses: docker/setup-buildx-action@v1 - - - name: "🔑 Login to GitHub Containers" - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: "đŸ”Ŋ Find the lowercase name of the repository" - id: reponame - uses: ASzc/change-string-case-action@v5 - with: - string: ${{ github.repository }} - - - name: "🏗 Build and push the Docker image" - uses: docker/build-push-action@v3 - with: - tags: >- - ghcr.io/${{ steps.reponame.outputs.lowercase }}:${{ steps.semver.outputs.precedence }}, - ghcr.io/${{ steps.reponame.outputs.lowercase }}:${{ steps.semver.outputs.core }}, - ghcr.io/${{ steps.reponame.outputs.lowercase }}:${{ steps.semver.outputs.pair }}, - ghcr.io/${{ steps.reponame.outputs.lowercase }}:${{ steps.semver.outputs.major }}, - ghcr.io/${{ steps.reponame.outputs.lowercase }}:latest - push: true + test: + uses: ./.github/workflows/test.yml + + ghcrio: + uses: Steffo99/.github/.github/workflows/buildrelease-docker.yml@main + needs: + - test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..215cbe9 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,17 @@ +name: "Test suite" + +on: + # Modification of a project file in the main branch + push: + branches: + - main + # Pull request to the main branch modifying a project file + pull_request: + branches: + - main + # Triggered by a new release + workflow_call: + +jobs: + test: + uses: Steffo99/.github/.github/workflows/test-poetry-compileall.yml@main diff --git a/Dockerfile b/Dockerfile index 81ed97b..3791ce9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,28 @@ -FROM python:3.10 AS labels -LABEL maintainer="Stefano Pigozzi " -LABEL description="A customizable, multilanguage Telegram shop bot" +FROM python:3.10-alpine AS dependencies +RUN apk add --update build-base python3-dev py-pip musl-dev -FROM labels AS dependencies -COPY requirements.txt ./requirements.txt -RUN pip install --no-cache-dir -r requirements.txt - -FROM dependencies AS greed -COPY . /usr/src/greed WORKDIR /usr/src/greed +COPY ./requirements.txt ./requirements.txt +RUN pip install --no-cache-dir --requirement requirements.txt + +############################################################################# + +FROM python:3.10-slim AS final + +COPY --from=dependencies /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages + +WORKDIR /usr/src/greed +COPY . /usr/src/greed -FROM greed AS entry ENTRYPOINT ["python", "-OO"] CMD ["core.py"] -FROM entry AS environment ENV PYTHONUNBUFFERED=1 ENV CONFIG_PATH="/etc/greed/config.toml" -ENV DB_ENGINE="sqlite:////var/lib/greed/database.sqlite" \ No newline at end of file +ENV DB_ENGINE="sqlite:////var/lib/greed/database.sqlite" + +LABEL org.opencontainers.image.title="greed" +LABEL org.opencontainers.image.description="A customizable, multilanguage Telegram shop bot" +LABEL org.opencontainers.image.licenses="AGPL-3.0-or-later" +LABEL org.opencontainers.image.url="https://github.com/Steffo99/greed/" +LABEL org.opencontainers.image.authors="Stefano Pigozzi " \ No newline at end of file