Skip to content

Commit 1289146

Browse files
authored
fix: improve redis connection reliability
* Use uv and mise. * Use virtool over virtool-workflow.
1 parent 486497a commit 1289146

File tree

12 files changed

+1347
-2695
lines changed

12 files changed

+1347
-2695
lines changed

.deepsource.toml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/CODEOWNERS

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/ci.yml renamed to .github/workflows/ci.yaml

Lines changed: 75 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: ci
1+
name: CI
22

33
on:
44
pull_request:
@@ -10,13 +10,17 @@ on:
1010

1111
workflow_dispatch:
1212

13+
permissions:
14+
contents: read
15+
1316
env:
17+
NODE_VERION: 22
1418
REGISTRY: ghcr.io
15-
TEST_TAG: user/create-subtraction:test
1619

1720
jobs:
1821
commitlint:
19-
runs-on: ubuntu-24.04
22+
name: "Commitlint"
23+
runs-on: ubuntu-latest
2024
if: github.event_name == 'pull_request'
2125
steps:
2226
- name: Checkout
@@ -26,40 +30,85 @@ jobs:
2630
- name: Commitlint
2731
uses: wagoid/commitlint-github-action@v6
2832
build:
29-
runs-on: ubuntu-24.04
33+
name: "Build"
34+
runs-on: ubuntu-latest
3035
steps:
3136
- name: Checkout
3237
uses: actions/checkout@v4
33-
- name: Build
34-
run: docker build --target base .
35-
test:
36-
runs-on: ubuntu-24.04
38+
- name: Set up Docker Buildx
39+
uses: docker/setup-buildx-action@v3
40+
- name: Build Docker Image
41+
uses: docker/build-push-action@v5
42+
with:
43+
context: .
44+
target: base
45+
push: false
46+
cache-from: type=gha
47+
cache-to: type=gha,mode=max
48+
tags: workflow-create-subtraction:base
49+
ruff-format:
50+
name: Ruff / Format
51+
runs-on: ubuntu-latest
3752
steps:
3853
- name: Checkout
3954
uses: actions/checkout@v4
40-
- name: Build
41-
id: build-push
42-
uses: docker/build-push-action@v5
55+
- name: Install mise
56+
uses: jdx/mise-action@v2
57+
- name: Install uv
58+
uses: astral-sh/setup-uv@v4
4359
with:
44-
context: .
45-
load: true
46-
tags: ${{ env.TEST_TAG }}
47-
target: test
60+
version: "latest"
61+
- name: Set up Python
62+
run: uv python install
63+
- name: Install dependencies
64+
run: uv sync
65+
- name: Check formatting
66+
run: uv run ruff format --check .
67+
ruff-lint:
68+
name: Ruff / Lint
69+
runs-on: ubuntu-latest
70+
steps:
71+
- name: Checkout
72+
uses: actions/checkout@v4
73+
- name: Install mise
74+
uses: jdx/mise-action@v2
75+
- name: Install uv
76+
uses: astral-sh/setup-uv@v4
77+
with:
78+
version: "latest"
79+
- name: Set up Python
80+
run: uv python install
81+
- name: Install dependencies
82+
run: uv sync
83+
- name: Check linting
84+
run: uv run ruff check .
85+
test:
86+
name: "Test"
87+
runs-on: ubuntu-latest
88+
needs: [build]
89+
steps:
90+
- name: Checkout
91+
uses: actions/checkout@v4
92+
- name: Set up Docker Buildx
93+
uses: docker/setup-buildx-action@v3
94+
- name: Install Mise
95+
uses: jdx/mise-action@v2
4896
- name: Test
49-
run: docker run ${{ env.TEST_TAG }}
97+
run: mise run test
5098
release:
51-
runs-on: ubuntu-24.04
99+
name: "Publish / Release"
100+
runs-on: ubuntu-latest
52101
if: github.event_name == 'push'
53-
needs: [build, test]
102+
needs: [test, commitlint]
103+
permissions:
104+
contents: write
54105
outputs:
55106
git-tag: ${{ steps.semantic.outputs.git-tag }}
56107
steps:
57108
- name: Checkout
58109
uses: actions/checkout@v4
59110
- name: Setup NodeJS
60111
uses: actions/setup-node@v4
61-
with:
62-
node-version: 22
63112
- name: Install semantic-release
64113
run: npm i semantic-release@v24.2.5 @semantic-release/exec@v7.1.0 conventional-changelog-conventionalcommits@9.0.0
65114
- name: Run semantic-release
@@ -69,9 +118,12 @@ jobs:
69118
run: npx semantic-release
70119

71120
ghcr:
72-
runs-on: ubuntu-24.04
73-
needs: [build, release, test]
121+
name: "Publish / GHCR"
122+
runs-on: ubuntu-latest
123+
needs: [release]
74124
if: github.repository_owner == 'Virtool'
125+
permissions:
126+
packages: write
75127
steps:
76128
- name: Checkout
77129
uses: actions/checkout@v4
@@ -98,4 +150,4 @@ jobs:
98150
labels: ${{ steps.meta.outputs.labels }}
99151
push: true
100152
tags: ${{ steps.meta.outputs.tags }}
101-
target: "base"
153+
target: "base"

Dockerfile

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,29 @@
1-
FROM debian:bookworm as bowtie2
2-
WORKDIR /build
3-
RUN apt-get update && apt-get install -y unzip wget
4-
RUN wget https://github.com/BenLangmead/bowtie2/releases/download/v2.3.2/bowtie2-2.3.2-legacy-linux-x86_64.zip && \
5-
unzip bowtie2-2.3.2-legacy-linux-x86_64.zip && \
6-
mkdir bowtie2 && \
7-
cp bowtie2-2.3.2-legacy/bowtie2* bowtie2
8-
9-
FROM debian:bookworm as pigz
10-
WORKDIR /build
11-
RUN apt-get update && apt-get install -y gcc make wget zlib1g-dev
12-
RUN wget https://zlib.net/pigz/pigz-2.8.tar.gz && \
13-
tar -xzvf pigz-2.8.tar.gz && \
14-
cd pigz-2.8 && \
15-
make
1+
FROM python:3.13-bookworm AS deps
2+
WORKDIR /workflow
3+
COPY --from=ghcr.io/virtool/tools:1.1.0 /tools/bowtie2/2.5.4/bowtie* /usr/local/bin/
4+
COPY --from=ghcr.io/virtool/tools:1.1.0 /tools/pigz/2.8/pigz /usr/local/bin/
165

17-
FROM python:3.12.3-bookworm as build
6+
FROM python:3.13-bookworm AS uv
187
WORKDIR /workflow
19-
RUN curl -sSL https://install.python-poetry.org | python -
8+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
209
ENV PATH="/root/.local/bin:${PATH}" \
21-
POETRY_CACHE_DIR='/tmp/poetry_cache' \
22-
POETRY_NO_INTERACTION=1 \
23-
POETRY_VIRTUALENVS_IN_PROJECT=1 \
24-
POETRY_VIRTUALENVS_CREATE=1
25-
COPY pyproject.toml poetry.lock ./
26-
RUN poetry install --without dev --no-root
10+
UV_CACHE_DIR='/tmp/uv_cache'
11+
COPY uv.lock pyproject.toml README.md ./
12+
RUN uv sync
2713

28-
FROM python:3.12.3-bookworm as base
14+
FROM deps AS base
2915
WORKDIR /workflow
30-
ENV VIRTUAL_ENV=/app/.venv \
31-
PATH="/workflow/.venv/bin:/opt/fastqc:${PATH}"
32-
COPY --from=bowtie2 /build/bowtie2/* /usr/local/bin/
33-
COPY --from=pigz /build/pigz-2.8/pigz /usr/local/bin/pigz
34-
COPY --from=build /workflow/.venv /workflow/.venv
16+
ENV PATH="/workflow/.venv/bin:/root/.local/bin:${PATH}"
17+
COPY --from=uv /workflow/.venv /workflow/.venv
3518
COPY fixtures.py workflow.py VERSION* ./
3619

37-
FROM build as test
20+
FROM deps AS test
3821
WORKDIR /workflow
39-
RUN curl -sSL https://install.python-poetry.org | python -
22+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
4023
ENV PATH="/root/.local/bin:${PATH}" \
41-
POETRY_CACHE_DIR='/tmp/poetry_cache' \
42-
POETRY_NO_INTERACTION=1 \
43-
POETRY_VIRTUALENVS_IN_PROJECT=1 \
44-
POETRY_VIRTUALENVS_CREATE=1
45-
COPY --from=build /workflow/.venv /workflow/.venv
46-
COPY pyproject.toml poetry.lock ./
47-
RUN poetry install
24+
UV_CACHE_DIR='/tmp/uv_cache'
25+
COPY uv.lock pyproject.toml ./
26+
COPY README.md ./
27+
RUN uv sync
4828
COPY fixtures.py workflow.py ./
4929
COPY tests/ ./tests/

README.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,3 @@ A workflow for creating Virtool subtractions.
99
3. Compress the FASTA file for upload and long term retention.
1010
4. Upload the index files to the Virtool server and add sequence count and nucleotide distribution data to
1111
the subtraction record.
12-
13-
## Contributing
14-
15-
### Commits
16-
17-
All commits must follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0) specification.
18-
19-
These standardized commit messages are used to automatically publish releases using [`semantic-release`](https://semantic-release.gitbook.io/semantic-release)
20-
after commits are merged to `main` from successful PRs.
21-
22-
**Example**
23-
24-
```text
25-
feat: add API support for assigning labels to existing samples
26-
```
27-
28-
Descriptive bodies and footers are required where necessary to describe the impact of the commit. Use bullets where appropriate.
29-
30-
Additional Requirements
31-
1. **Write in the imperative**. For example, _"fix bug"_, not _"fixed bug"_ or _"fixes bug"_.
32-
2. **Don't refer to issues or code reviews**. For example, don't write something like this: _"make style changes requested in review"_.
33-
Instead, _"update styles to improve accessibility"_.
34-
3. **Commits are not your personal journal**. For example, don't write something like this: _"got server running again"_
35-
or _"oops. fixed my code smell"_.
36-
37-
From Tim Pope: [A Note About Git Commit Messages](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)

docker-compose.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
services:
2+
test:
3+
build:
4+
context: .
5+
target: test
6+
volumes:
7+
# Mount entire project directory
8+
- .:/workflow
9+
# Persistent volumes for build artifacts
10+
- venv-data:/workflow/.venv
11+
- uv-cache:/tmp/uv_cache
12+
working_dir: /workflow
13+
command: sleep infinity
14+
15+
volumes:
16+
venv-data:
17+
uv-cache:

mise.toml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[tools]
2+
uv = "latest"
3+
4+
[vars]
5+
test_exec = "docker compose exec test"
6+
7+
[tasks."test"]
8+
description = "Run Python tests in container"
9+
depends = ["test:start"]
10+
run = [
11+
"{{vars.test_exec}} bash -c 'uv sync'",
12+
'{{vars.test_exec}} uv run pytest {{arg(name="pytest_args", var=true, default="")}}'
13+
]
14+
15+
[tasks."test:bash"]
16+
description = "Open interactive shell in test container"
17+
run = "{{vars.test_exec}} bash"
18+
19+
[tasks."test:rebuild"]
20+
description = "Force rebuild the test container"
21+
run = [
22+
"docker compose down -v --remove-orphans",
23+
"docker compose build test",
24+
"docker compose up -d"
25+
]
26+
27+
[tasks."test:start"]
28+
description = "Start the test container"
29+
run = "docker compose up -d test"
30+
31+
[tasks."test:stop"]
32+
description = "Stop the test container"
33+
run = "docker compose down --remove-orphans"

0 commit comments

Comments
 (0)