Skip to content

Commit

Permalink
Merge pull request #849 from carmenbianca/less-ci
Browse files Browse the repository at this point in the history
Save the penguins; run fewer tests in CI
  • Loading branch information
carmenbianca authored Oct 24, 2023
2 parents 28b8c60 + b1e93be commit 6c3de58
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 195 deletions.
134 changes: 11 additions & 123 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

name: Docker Images - test, build and push
name: Docker

on:
push:
Expand All @@ -14,9 +14,6 @@ on:
# - latest"
tags:
- "v*.*.*"
# Main branch will be "dev"
branches:
- main
# On PRs only do tests
pull_request:

Expand All @@ -25,28 +22,21 @@ jobs:
# Test Docker images
# ===========================================================================
docker_test:
name: Test the docker images
runs-on: ubuntu-latest
name: Test the Docker images
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
# Dockerfile
- name: Build Dockerfile
run: |
docker build -t reuse -f docker/Dockerfile .
docker build -t reuse -f Dockerfile .
- name: Run Docker image
run: |
docker run -v "$(pwd):/data" reuse
# Dockerfile-extra
- name: Build Dockerfile-extra
run: |
docker build -t reuse-extra -f docker/Dockerfile-extra .
- name: Run Docker extra image
run: |
docker run -v "$(pwd):/data" reuse-extra
# Dockerfile-debian
- name: Build Dockerfile-debian
run: |
docker build -t reuse-debian -f docker/Dockerfile-debian .
docker build -t reuse-debian -f Dockerfile-debian .
- name: Run Docker debian image
run: |
docker run -v "$(pwd):/data" reuse-debian
Expand All @@ -55,8 +45,8 @@ jobs:
# Build and push Docker images for tagged releases
# ===========================================================================
docker_push_tag:
name: Push Docker image for tags to Docker Hub
runs-on: ubuntu-latest
name: Push Docker images for tags to Docker Hub
runs-on: ubuntu-22.04
# Depends on successful Docker build/test
needs:
- docker_test
Expand All @@ -78,7 +68,7 @@ jobs:
password: ${{ secrets.DOCKER_TOKEN }}

# Dockerfile
- name: Default Docker - set metadata
- name: Alpine Docker - set metadata
id: meta_default
uses: docker/metadata-action@v3
with:
Expand All @@ -87,38 +77,16 @@ jobs:
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
- name: Default Docker - build and push
- name: Alpine docker - build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/Dockerfile
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta_default.outputs.tags }}
labels: ${{ steps.meta_default.outputs.labels }}

# Dockerfile-extra
- name: Extra Docker - set metadata
id: meta_extra
uses: docker/metadata-action@v3
with:
images: fsfe/reuse
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
flavor: |
suffix=-extra,onlatest=true
- name: Extra Docker - build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/Dockerfile-extra
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta_extra.outputs.tags }}
labels: ${{ steps.meta_extra.outputs.labels }}

# Dockerfile-debian
- name: Debian Docker - set metadata
id: meta_debian
Expand All @@ -135,87 +103,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/Dockerfile-debian
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta_debian.outputs.tags }}
labels: ${{ steps.meta_debian.outputs.labels }}

# ===========================================================================
# Build and push Docker images for main branch updated (dev tag)
# ===========================================================================
docker_push_dev:
name: Push Docker image for main branch to Docker Hub
runs-on: ubuntu-latest
# Depends on successful Docker build/test
needs:
- docker_test
if:
${{ github.event_name != 'pull_request' && ( github.ref ==
'refs/heads/main' ) }}
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

# Dockerfile
- name: Default Docker - set metadata
id: meta_default
uses: docker/metadata-action@v3
with:
images: fsfe/reuse
tags: |
type=raw,value=dev
- name: Default Docker - build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta_default.outputs.tags }}
labels: ${{ steps.meta_default.outputs.labels }}

# Dockerfile-extra
- name: Extra Docker - set metadata
id: meta_extra
uses: docker/metadata-action@v3
with:
images: fsfe/reuse
tags: |
type=raw,value=dev-extra
- name: Extra Docker - build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/Dockerfile-extra
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta_extra.outputs.tags }}
labels: ${{ steps.meta_extra.outputs.labels }}

# Dockerfile-debian
- name: Debian Docker - set metadata
id: meta_debian
uses: docker/metadata-action@v3
with:
images: fsfe/reuse
tags: |
type=raw,value=dev-debian
- name: Debian Docker - build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/Dockerfile-debian
file: ./Dockerfile-debian
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta_debian.outputs.tags }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gettext.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

jobs:
create-pot:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/license_list_up_to_date.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
license-list-up-to-date:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
with:
Expand Down
19 changes: 8 additions & 11 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
# do not abort the whole test job if one combination in the matrix fails
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-20.04]
python-version: ["3.8", "3.12"]
os: [ubuntu-22.04]
include:
- python-version: "3.8"
os: macos-latest
Expand All @@ -43,7 +43,7 @@ jobs:
poetry run pytest --cov=reuse
pylint:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand All @@ -59,7 +59,7 @@ jobs:
poetry run pylint src/reuse/ tests/
black:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand All @@ -76,7 +76,7 @@ jobs:
poetry run black .
mypy:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand All @@ -92,7 +92,7 @@ jobs:
poetry run mypy
prettier:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
container: node:latest
steps:
- uses: actions/checkout@v2
Expand All @@ -102,10 +102,7 @@ jobs:
run: npx prettier --check .

reuse:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-latest, windows-latest]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand All @@ -121,7 +118,7 @@ jobs:
make reuse
docs:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/third_party_lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:

jobs:
third-party-lint:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
# do not abort the whole test job if one combination in the matrix fails
fail-fast: false
Expand All @@ -45,7 +45,7 @@ jobs:
matrix.repo }}

third-party-lint-expect-failure:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
# do not abort the whole test job if one combination in the matrix fails
fail-fast: false
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ CLI command and its behaviour. There are no guarantees of stability for the
REUSE information. (#825)
- `--force-dot-license` and `--skip-unrecognised` are now mutually exclusive on
`annotate`. (#852)
- No longer create and publish `-extra` Docker images. The `openssh-client`
package is now in the main image. (#849)
- No longer create and publish `dev` Docker images. (#849)
- The `-debian` Docker image is now based off debian:12-slim. It used to be
based on the python:slim image, which used debian:slim under the hood. (#849)

### Deprecated

Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Create a base image that has dependencies installed.
FROM alpine:3.18 AS base

RUN apk --no-cache add git mercurial python3
RUN apk --no-cache add git mercurial python3 openssh-client

# Build reuse into a virtualenv
FROM base AS build
Expand All @@ -20,7 +20,7 @@ ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

RUN poetry install --no-interaction --no-dev --no-root
RUN poetry install --no-interaction --no-root --only main
RUN poetry build --no-interaction
RUN pip install dist/*.whl

Expand Down
14 changes: 6 additions & 8 deletions docker/Dockerfile-debian → Dockerfile-debian
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,30 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

# Like normal Dockerfile, but based on python:slim (Debian) to ease compliance

# Create a base image that has dependencies installed.
FROM python:slim AS base
FROM debian:12-slim AS base

RUN apt-get update \
&& apt-get install -y git mercurial \
&& apt-get -y upgrade \
&& apt-get -y --no-install-recommends install git mercurial python3 \
&& apt-get -y clean \
&& rm -rf /var/lib/apt/lists/*

# Build reuse into a virtualenv
FROM base AS build

RUN apt-get update \
&& apt-get install -y python3-dev python3-pip gettext \
&& apt-get -y --no-install-recommends install python3-venv python3-poetry python3-pip python3-wheel gettext \
&& rm -rf /var/lib/apt/lists/*

RUN pip install poetry

WORKDIR /reuse-tool
COPY . /reuse-tool/

ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

RUN poetry install --no-interaction --no-dev --no-root
RUN poetry install --no-interaction --no-root --only main
RUN poetry build --no-interaction
RUN pip install dist/*.whl

Expand Down
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,16 @@ You can also provide additional arguments, like so:
docker run --rm --volume $(pwd):/data fsfe/reuse --include-submodules spdx -o out.spdx
```

There are a number of tags available:

- `latest` is the most recent stable release.
- `dev` follows the `main` branch of this repository. Up-to-date, but
potentially unstable.
- `latest-extra` has a few extra packages installed, currently `openssh-client`.
- `latest-debian` is based on `python:slim`. It is larger, but may be better
suited for license compliance.
The available tags are:

- `latest` --- the most recent release of reuse.
- `{major}` --- the latest major release.
- `{major}.{minor}` --- the latest minor release.
- `{major}.{minor}.{patch}` --- a precise release.

You can add `-debian` to any of the tags to get a Debian-based instead of an
Alpine-based image, which is larger, but may be better suited for license
compliance.

### Run as pre-commit hook

Expand Down
Loading

0 comments on commit 6c3de58

Please sign in to comment.