Skip to content

Commit

Permalink
ci: 优化 actions
Browse files Browse the repository at this point in the history
  • Loading branch information
he0119 committed Feb 7, 2022
1 parent af000fc commit aff29eb
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 51 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ indent_size = 4
[*.md]
max_line_length = off
insert_final_newline = false

[*.yml]
trim_trailing_whitespace = true
1 change: 0 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
uses: docker/build-push-action@v2
with:
context: .
file: base.Dockerfile
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
22 changes: 6 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,17 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
uses: he0119/setup-python@main
with:
python-version: 3.9
- name: Install poetry
uses: Gr1N/setup-poetry@v7
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}

- name: Install prerequisites
run: poetry install

- name: Run tests
run: poetry run pytest --cov=src --cov-report xml --junitxml=TEST-pytest.xml
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v2
with:
name: Unit Test Results
path: |
**/TEST-*.xml
run: poetry run pytest --cov=src --cov-report xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
27 changes: 26 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
FROM ghcr.io/nonebot/nonebot2-publish-bot:sha-4e2681c
FROM python:3.9 as requirements-stage

WORKDIR /tmp

COPY ./pyproject.toml ./poetry.lock* /tmp/

RUN curl -sSL https://install.python-poetry.org -o install-poetry.py

RUN python install-poetry.py --yes

ENV PATH="${PATH}:/root/.local/bin"

RUN poetry export -f requirements.txt --output requirements.txt --without-hashes

FROM python:3.9-slim-bullseye

WORKDIR /app

RUN apt-get update \
&& apt-get install -y --no-install-recommends git \
&& apt-get purge -y --auto-remove \
&& rm -rf /var/lib/apt/lists/*

COPY --from=requirements-stage /tmp/requirements.txt /app/requirements.txt

RUN pip install --no-cache-dir --upgrade -r requirements.txt

RUN rm requirements.txt

COPY ./main.py /app/
COPY ./src /app/src

Expand Down
33 changes: 0 additions & 33 deletions base.Dockerfile

This file was deleted.

0 comments on commit aff29eb

Please sign in to comment.