-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added CICD (#28) * Revert some changes. * Add Dockerfile. * Add github actions. * Add some operation stuff. * Comment build and deploy stages in CI/CD. --------- Co-authored-by: GolovkinAlexander <112856471+GolovkinAlexander@users.noreply.github.com>
- Loading branch information
1 parent
30dd56c
commit ca63376
Showing
9 changed files
with
198 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.git | ||
.idea | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[flake8] | ||
ignore = E501, E203, E305, F401, F541 | ||
exclude = | ||
.venv, | ||
.git, | ||
__pycache__ | ||
max-line-length = 120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: KrdDevBot CI/CD Pipeline | ||
|
||
on: | ||
push: | ||
branches: | ||
- cicd | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
- name: Install PDM | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pdm | ||
- name: Install dependencies using PDM | ||
run: | | ||
pdm install --dev | ||
- name: Run tests | ||
run: | | ||
pdm run pytest | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
- name: Install PDM | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pdm | ||
- name: Install dependencies using PDM | ||
run: | | ||
pdm install --dev | ||
- name: Run linters | ||
run: | | ||
pdm run flake8 | ||
# build: | ||
# needs: [test, lint] | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Checkout code | ||
# uses: actions/checkout@v4 | ||
# - name: Set up Docker Buildx | ||
# uses: docker/setup-buildx-action@v3 | ||
# - name: Login to Docker Hub | ||
# uses: docker/login-action@v3 | ||
# with: | ||
# username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
# password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
# - name: Build and push | ||
# uses: docker/build-push-action@v5 | ||
# with: | ||
# push: true | ||
# tags: krddev/bot:$GITHUB_REF_TYPE | ||
# | ||
# deploy: | ||
# needs: [build] | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Add SSH key | ||
# uses: webfactory/ssh-agent@v0.5.3 | ||
# with: | ||
# ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
# | ||
# - name: Deploy | ||
# run: | | ||
# ssh -o StrictHostKeyChecking=no ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} << 'EOF' | ||
# cd ~/krddevbot | ||
# git pull | ||
# docker build -t krddev/bot:main . | ||
# sudo systemctl restart krddevbot.service | ||
# EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
ARG PYTHON_BASE=3.10-slim | ||
|
||
FROM python:$PYTHON_BASE AS builder | ||
|
||
ENV PDM_CHECK_UPDATE=false | ||
|
||
WORKDIR /app | ||
|
||
RUN pip install --no-cache-dir -U pdm \ | ||
&& find /usr/local/lib -name "*.pyc" -exec rm -f {} \; | ||
|
||
COPY pyproject.toml pdm.lock /app/ | ||
|
||
RUN pdm install --check --prod --no-editable \ | ||
&& find /usr/local/lib -name "*.pyc" -exec rm -f {} \; | ||
|
||
RUN pdm export --dev --without-hashes > /app/.venv/requirements.txt | ||
|
||
FROM python:$PYTHON_BASE | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=builder /app/.venv/ /app/.venv | ||
|
||
ENV PATH="/app/.venv/bin:$PATH" | ||
COPY . . | ||
|
||
CMD ["python3", "-m", "krddevbot"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: '3' | ||
|
||
services: | ||
krddevbot: | ||
image: krddev/bot:main | ||
container_name: krddevbot | ||
restart: always | ||
volumes: | ||
- ~/krddevbot/tander:/app/tander | ||
env_file: | ||
- ~/krddevbot/.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[Unit] | ||
Description=KrdDevBot systemd service | ||
PartOf=docker.service | ||
After=docker.service | ||
|
||
[Service] | ||
Type=oneshot | ||
User=krddev | ||
RemainAfterExit=true | ||
WorkingDirectory=/home/krddev/ | ||
ExecStart=docker compose up -d --remove-orphans | ||
ExecStop=docker compose down | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,5 @@ bot = "python -m krddevbot" | |
[tool.pdm.dev-dependencies] | ||
dev = [ | ||
"pytest>=8.0.0", | ||
] | ||
"flake8>=5.0.0", | ||
] |