diff --git a/.cirrus.yml b/.cirrus.yml index b18f42b..c9777c4 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,118 +1,76 @@ lint_task: + environment: + CIRRUS_SHELL: direct container: - image: python:3-slim - install_script: - - pip3 install ruff + image: ghcr.io/astral-sh/ruff script: - - ruff check - -archlinux_and_manjaro_task: - container: - matrix: - - image: archlinux:latest - - image: manjarolinux/base:latest - install_script: pacman -Sy --noconfirm python3 - script: python3 ./check_versions.py - json_artifacts: - path: "source/*.json" + - /ruff check -fedora_task: - container: - matrix: - - image: fedora:latest - script: python3 ./check_versions.py - json_artifacts: - path: "source/*.json" +check_versions_task: + matrix: + - freebsd_instance: {image_family: freebsd-14-0} + - container: {image: fedora:latest} + - container: + matrix: + - image: archlinux:latest + - image: manjarolinux/base:latest + install_script: pacman -Sy --noconfirm python3 -opensuse_task: - container: - matrix: - - image: opensuse/leap:latest - - image: opensuse/tumbleweed:latest - install_script: zypper install --no-confirm python3 - script: python3 ./check_versions.py - json_artifacts: - path: "source/*.json" + - container: + matrix: + - image: debian:oldstable-slim + - image: debian:stable-slim + - image: ubuntu:latest + install_script: + - apt-get -y update + - apt-get -y install python3 -debian_and_ubuntu_task: - container: - matrix: - - image: debian:oldstable-slim - - image: debian:stable-slim - - image: ubuntu:latest # Most recent LTS - see https://hub.docker.com/_/ubuntu - install_script: - - apt-get -y update - - apt-get -y install python3 - script: python3 ./check_versions.py - json_artifacts: - path: "source/*.json" + - container: + matrix: + - image: opensuse/leap:latest + - image: opensuse/tumbleweed:latest + install_script: zypper install --no-confirm python3 -freebsd_task: - freebsd_instance: - matrix: - - image_family: freebsd-14-0 script: python3 ./check_versions.py json_artifacts: path: "source/*.json" -task: - name: site gen success - container: - image: busybox +render_task: depends_on: - lint - - archlinux_and_manjaro - - fedora - - opensuse - - debian_and_ubuntu - - freebsd - -# Generate the site and publish it, for main branch. -publish_task: - only_if: $BRANCH == 'main' - depends_on: - - site gen success + - check_versions container: - image: node:20-bookworm - env: - NETLIFY_AUTH_TOKEN: ENCRYPTED[ec6da05d365917ed543e307555cbd9c618bbd41db7dee828daf7b01825adef48f547db89ead63b99418fe07a9d41b43a] - NETLIFY_SITE_ID: ENCRYPTED[a408add4551cd62fe8a5a912569fda66b5e991dd1097a8eaf0a6479179a07a6ec3e5d9e0c67d16f61c67a6721a728a91] + image: python:3-slim install_script: - - apt-get -y update - - apt-get -y install python3 python3-lxml - # https://github.com/netlify/cli/issues/1870 - - npm install --unsafe-perm=true -g netlify-cli + - pip install lxml script: - python3 -m generate_site $CIRRUS_BUILD_ID - stat _site/index.html - - netlify deploy --auth $NETLIFY_AUTH_TOKEN --site $NETLIFY_SITE_ID --dir=_site --prod + - tar -cf site.tar _site/ + site_artifacts: + path: "site.tar" -# Generates the site but don't publish it, for non-main branches. -fake_publish_task: - only_if: $BRANCH != 'main' +# Publish updates merged to the main branch +publish_task: + skip: $BRANCH != 'main' depends_on: - - site gen success + - render container: image: node:20-bookworm + env: + TOKEN: + ENCRYPTED[ec6da05d365917ed543e307555cbd9c618bbd41db7dee828daf7b01825adef48f547db89ead63b99418fe07a9d41b43a] + SITE_ID: + ENCRYPTED[a408add4551cd62fe8a5a912569fda66b5e991dd1097a8eaf0a6479179a07a6ec3e5d9e0c67d16f61c67a6721a728a91] install_script: - - apt-get -y update - - apt-get -y install python3 python3-lxml # https://github.com/netlify/cli/issues/1870 - npm install --unsafe-perm=true -g netlify-cli script: - - python3 -m generate_site $CIRRUS_BUILD_ID - - stat _site/index.html - -task: - only_if: $BRANCH == 'main' - name: CI success - container: {image: busybox} - depends_on: - - publish + - wget "https://api.cirrus-ci.com/v1/artifact/build/${CIRRUS_BUILD_ID}/render/site/site.tar" -O - | tar -vx + - netlify deploy --auth $TOKEN --site $SITE_ID --dir=_site --prod task: - only_if: $BRANCH != 'main' name: CI success container: {image: busybox} depends_on: - - fake_publish + - publish # marked as successful on skip diff --git a/check_versions.py b/check_versions.py index 669f149..3f199fb 100755 --- a/check_versions.py +++ b/check_versions.py @@ -204,7 +204,8 @@ def discover(): if sys.platform.startswith('freebsd'): os_name = 'FreeBSD' os_desc = run('uname -sr') - else: # Assume everything else is Linux. + + elif sys.platform == "linux": # Treat /etc/os-release as a key/value pair of strings, # with optional quotes on the value side. os_release = {k: v[1:-1] if v[0] == '"' else v for (k, v) in [line.split("=") for line in Path("/etc/os-release").read_text().splitlines() if not line.startswith("#")]} @@ -212,6 +213,9 @@ def discover(): os_version = os_release.get('VERSION_ID', '') os_desc = '{} {}'.format(os_name, os_version).strip() + else: + raise NotImplementedError(f"Only FreeBSD and Linux are currenctly supported, not '{sys.platform}'") + return DISTROS[os_name](os_name, os_desc) diff --git a/generate_site/__init__.py b/generate_site/__init__.py index 5ba5724..0f143fe 100644 --- a/generate_site/__init__.py +++ b/generate_site/__init__.py @@ -37,12 +37,12 @@ def build_index(directory): ]) -def download_data(build_id, os_name): +def download_data(build_id, task_name = 'check_versions'): """Download relevant Cirrus CI artifacts.""" Path('_data').mkdir(exist_ok=True) uri_domain = 'https://api.cirrus-ci.com' - uri_path = '/v1/artifact/build/{}/{}/json.zip'.format(build_id, os_name) + uri_path = '/v1/artifact/build/{}/{}/json.zip'.format(build_id, task_name) print('Downloading {}{}...'.format(uri_domain, uri_path))