Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/actions/run-pytest/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Run pytest with Trunk upload
description: Run a pytest target with JUnit output and optional Trunk Flaky Tests upload.

inputs:
junit-path:
description: Path to write the JUnit XML report.
required: true
pytest-args:
description: Arguments passed to pytest.
required: true
trunk-api-token:
description: Trunk API token. Leave empty to skip upload.
required: false
default: ""
trunk-org-slug:
description: Trunk organization URL slug.
required: true

runs:
using: composite
steps:
- name: Run pytest
id: pytest
shell: bash
run: |
mkdir -p "$(dirname "${{ inputs.junit-path }}")"
rm -f "${{ inputs.junit-path }}"
set +e
python -m pytest \
${{ inputs.pytest-args }} \
--junit-xml="${{ inputs.junit-path }}" \
-o junit_family=xunit1
status=$?
echo "exit_code=${status}" >> "${GITHUB_OUTPUT}"
exit 0

- name: Upload test results to Trunk
if: ${{ always() && inputs.trunk-api-token != '' }}
continue-on-error: true
uses: trunk-io/analytics-uploader@95a0fb8b29e45b6068304261fb518644b426a803 # v2.0.8
env:
TRUNK_API_TOKEN: ${{ inputs.trunk-api-token }}
with:
junit-paths: ${{ inputs.junit-path }}
org-slug: ${{ inputs.trunk-org-slug }}
token: ${{ inputs.trunk-api-token }}

- name: Fail if pytest failed
if: ${{ steps.pytest.outputs.exit_code != '0' }}
shell: bash
run: exit 1
90 changes: 26 additions & 64 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- scripts/**
- tests/**
- .trunk/**
- .github/actions/**
- upstream.toml
- sure-aio.xml
- renovate.json
Expand All @@ -29,6 +30,7 @@ on:
- scripts/**
- tests/**
- .trunk/**
- .github/actions/**
- upstream.toml
- sure-aio.xml
- renovate.json
Expand All @@ -41,6 +43,7 @@ env:
IMAGE_NAME: jsonbored/sure-aio
PYTHON_VERSION: "3.13"
TRUNK_ORG_URL_SLUG: aethereal
DOCKER_CACHE_SCOPE: sure-aio-image

permissions:
contents: read
Expand Down Expand Up @@ -151,7 +154,7 @@ jobs:
CHANGELOG.md|cliff.toml|scripts/*|.trunk/*)
tooling_related=true
;;
.github/workflows/*)
.github/actions/**|.github/workflows/*)
tooling_related=true
workflow_related=true
;;
Expand Down Expand Up @@ -216,12 +219,15 @@ jobs:
import re
import sys

workflow_dir = pathlib.Path(".github/workflows")
workflow_paths = [
*pathlib.Path(".github/workflows").glob("*.yml"),
*pathlib.Path(".github/actions").glob("*/action.yml"),
]
pattern = re.compile(r"^\s*uses:\s*([^@\s]+)@([^\s#]+)")
sha_pattern = re.compile(r"^[0-9a-f]{40}$")
failures = []

for path in sorted(workflow_dir.glob("*.yml")):
for path in sorted(workflow_paths):
for lineno, line in enumerate(path.read_text().splitlines(), start=1):
match = pattern.match(line)
if not match:
Expand Down Expand Up @@ -271,35 +277,13 @@ jobs:
- name: Install pytest
run: python -m pip install -r requirements-dev.txt

- name: Run pytest unit tests
id: unit_pytest
run: |
mkdir -p reports
rm -f reports/pytest-unit.xml
set +e
python -m pytest \
tests/unit \
tests/template \
--junit-xml=reports/pytest-unit.xml \
-o junit_family=xunit1
status=$?
echo "exit_code=${status}" >> "${GITHUB_OUTPUT}"
exit 0

- name: Upload unit test results to Trunk
if: ${{ always() && env.TRUNK_API_TOKEN != '' }}
continue-on-error: true
uses: trunk-io/analytics-uploader@95a0fb8b29e45b6068304261fb518644b426a803 # v2.0.8
env:
TRUNK_API_TOKEN: ${{ secrets.TRUNK_API_TOKEN }}
- name: Run unit and template tests
uses: ./.github/actions/run-pytest
with:
junit-paths: reports/pytest-unit.xml
org-slug: ${{ env.TRUNK_ORG_URL_SLUG }}
token: ${{ env.TRUNK_API_TOKEN }}

- name: Fail if unit tests failed
if: ${{ steps.unit_pytest.outputs.exit_code != '0' }}
run: exit 1
junit-path: reports/pytest-unit.xml
pytest-args: tests/unit tests/template
trunk-api-token: ${{ env.TRUNK_API_TOKEN }}
trunk-org-slug: ${{ env.TRUNK_ORG_URL_SLUG }}

integration-tests:
if: ${{ needs.detect-changes.outputs.run_tests_requested == 'true' && (needs.detect-changes.outputs.build_related == 'true' || (github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.detect-changes.outputs.publish_requested == 'true')) }}
Expand Down Expand Up @@ -330,51 +314,29 @@ jobs:
platforms: linux/amd64
load: true
tags: sure-aio:pytest
cache-from: type=gha,scope=sure-aio-pytest
cache-to: type=gha,mode=max,scope=sure-aio-pytest
cache-from: type=gha,scope=${{ env.DOCKER_CACHE_SCOPE }}
cache-to: type=gha,mode=max,scope=${{ env.DOCKER_CACHE_SCOPE }}

- name: Install pytest
run: python -m pip install -r requirements-dev.txt

- name: Run pytest integration tests
id: integration_pytest
- name: Run integration tests
env:
AIO_PYTEST_USE_PREBUILT_IMAGE: "true"
run: |
mkdir -p reports
rm -f reports/pytest-integration.xml
set +e
python -m pytest \
tests/integration \
-m integration \
--junit-xml=reports/pytest-integration.xml \
-o junit_family=xunit1
status=$?
echo "exit_code=${status}" >> "${GITHUB_OUTPUT}"
exit 0

- name: Upload integration test results to Trunk
if: ${{ always() && env.TRUNK_API_TOKEN != '' }}
continue-on-error: true
uses: trunk-io/analytics-uploader@95a0fb8b29e45b6068304261fb518644b426a803 # v2.0.8
env:
TRUNK_API_TOKEN: ${{ secrets.TRUNK_API_TOKEN }}
uses: ./.github/actions/run-pytest
with:
junit-paths: reports/pytest-integration.xml
org-slug: ${{ env.TRUNK_ORG_URL_SLUG }}
token: ${{ env.TRUNK_API_TOKEN }}
junit-path: reports/pytest-integration.xml
pytest-args: tests/integration -m integration
trunk-api-token: ${{ env.TRUNK_API_TOKEN }}
trunk-org-slug: ${{ env.TRUNK_ORG_URL_SLUG }}

- name: Dump Docker diagnostics
if: ${{ failure() || (steps.integration_pytest.conclusion == 'success' && steps.integration_pytest.outputs.exit_code != '0') }}
if: ${{ failure() }}
run: |
docker ps -a
echo
docker images

- name: Fail if integration tests failed
if: ${{ steps.integration_pytest.outputs.exit_code != '0' }}
run: exit 1

publish:
if: ${{ (needs.detect-changes.outputs.build_related == 'true' || needs.detect-changes.outputs.xml_related == 'true') && github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.detect-changes.outputs.publish_requested == 'true' && needs.integration-tests.result == 'success' }}
needs:
Expand Down Expand Up @@ -506,8 +468,8 @@ jobs:
context: .
platforms: linux/amd64,linux/arm64
push: true
cache-from: type=gha,scope=sure-aio-publish
cache-to: type=gha,mode=max,scope=sure-aio-publish
cache-from: type=gha,scope=${{ env.DOCKER_CACHE_SCOPE }}
cache-to: type=gha,mode=max,scope=${{ env.DOCKER_CACHE_SCOPE }}
tags: ${{ steps.prep.outputs.tags }}
labels: |
org.opencontainers.image.source=https://github.com/JSONbored/sure-aio
Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,13 @@ RUN find /etc/s6-overlay/s6-rc.d -type f \( -name "run" -o -name "up" \) -exec c
# 4. Expose the App Storage
VOLUME ["/rails/storage", "/var/lib/postgresql/data", "/var/lib/redis"]

EXPOSE 3000

ENV SKYLIGHT_ENABLED=false
ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=300000
ENV S6_BEHAVIOUR_IF_STAGE2_FAILS=2

HEALTHCHECK --interval=30s --timeout=10s --start-period=180s --retries=3 \
CMD curl -f http://localhost:3000/up || exit 1
CMD curl -fsS http://localhost:3000/up >/dev/null || exit 1

ENTRYPOINT ["/init"]
4 changes: 2 additions & 2 deletions scripts/validate-template.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@
"Full changelog and release notes:",
)
ALLOWED_CATEGORY_TOKENS = {
"Productivity",
"Tools-Utilities",
"Productivity:",
"Tools:Utilities",
}


Expand Down
2 changes: 1 addition & 1 deletion sure-aio.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
- Always publish on manual main workflow dispatch
- Let manual publish proceed when smoke test is skipped
- Trigger package publish for aio tag alignment</Changes>
<Category>Productivity Tools-Utilities</Category>
<Category>Productivity: Tools:Utilities</Category>
<WebUI>http://[IP]:[PORT:3000]</WebUI>
<TemplateURL>https://raw.githubusercontent.com/JSONbored/awesome-unraid/main/sure-aio.xml</TemplateURL>
<Icon>https://raw.githubusercontent.com/JSONbored/awesome-unraid/main/icons/sure.png</Icon>
Expand Down
Loading
Loading