Skip to content

Commit

Permalink
Merge pull request #1 from cmu-sei/feature/ci
Browse files Browse the repository at this point in the history
Feature/ci
  • Loading branch information
sei-kpitstick authored Jan 9, 2025
2 parents c2b95e5 + b0607b4 commit dda6271
Show file tree
Hide file tree
Showing 12 changed files with 326 additions and 65 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Vessel Linting, Tests and Docker Image Creation

on:
- push
- pull_request

jobs:
lint_and_test:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install poetry
run: curl -sSL https://install.python-poetry.org | python -
- name: Install dependencies
run: poetry install --with qa,extra_dependencies
- name: Check import sorting
run: make check-isort
- name: Check format
run: make check-format
- name: Lint code
run: make check-lint
- name: Check types
run: make check-typecheck
# - name: Execute unit tests
# run: make test

docker:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Docker Build Action
run: docker build -t vessel .
66 changes: 66 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Automation of various common tasks

# -----------------------------------------------------------------------------
# QA
# -----------------------------------------------------------------------------

# Sort imports.
.PHONY: isort
isort:
poetry run ruff check --select I --fix

.PHONY: check-isort
check-isort:
poetry run ruff check --select I

# Format all source code
.PHONY: format
format:
poetry run ruff format

.PHONY: check-format
check-format:
poetry run ruff format --check

# Lint all source code and workflows
.PHONY: lint
lint:
poetry run ruff check --fix
poetry run actionlint

.PHONY: check-lint
check-lint:
poetry run ruff check
poetry run actionlint

# Typecheck all source code
.PHONY: typecheck
typecheck:
poetry run mypy vessel/

.PHONY: check-typecheck
check-typecheck: typecheck

# Clean cache files
.PHONY: clean
clean:
rm -r -f .mypy_cache .pytest_cache .ruff_cache

# All quality assurance
.PHONY: qa
qa: isort format lint typecheck

# Check all QA tasks
.PHONY: check
check: check-isort check-format check-lint check-typecheck

# Run unit tests with pytest
.PHONY: test
test:
poetry run pytest test

# -----------------------------------------------------------------------------
# All actions and checks equivalent to what the CI does.
# -----------------------------------------------------------------------------
.PHONY: ci
ci: clean check test
43 changes: 26 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

Vessel is a project with the goal of promoting reproducible container builds. The first version of the Vessel tool has one command, `diff`, that compares two built container images and reports on differences between them, flagging as many known issues as possible. The goal of this command is to allow the detection of reproducibility issues when building container images, so that developers can take the appropriate measures to increase reproducibility.

## Dependencies
## Setup

### Local Environment Setup

Pre-requisites:
* Linux OS - tested on Ubuntu 22.04
Expand All @@ -12,7 +14,7 @@ Pre-requisites:

To set up the Python environment and the required packages:
1. `poetry shell`
2. `poetry install`
2. `poetry install --with extra_dependencies`

To set up additional external tools that are used:
* Install the skopeo package (e.g., `apt-get install skopeo`)
Expand All @@ -24,10 +26,17 @@ To set up additional external tools that are used:
* Run `diffoscope --list-tools` for a full list. Also, the Dockerfile
should install all of them.

Note that it is much simpler to run Vessel in a Docker container, which already contains all these dependencies. See [Docker](#docker).
Note that it is much simpler to run Vessel in a Docker container, which already contains all these dependencies. See [Docker Setup](#docker-setup).

### Docker Setup

Assuming you have Docker installed, run the following to build the vessel docker image.

* `docker build -t vessel .`

## Running

### In Local Environment
The tool can be run locally like this:

1. Make sure the environment is active: `poetry shell`
Expand All @@ -36,14 +45,6 @@ The tool can be run locally like this:

Run `vessel --help` for full list of commands and options.

## Docker

### Building the Docker image

Assuming you have Docker installed, run:

* `docker build -t vessel .`

### Running the Docker container

* Note: Running within Docker avoids permission issues during the unpacking of the images
Expand All @@ -64,14 +65,22 @@ Example running on two images from a private Docker registry:

## Development

To lint the code, execute:
* `ruff check`
Follow the instructions at [Local Environment Setup](#local-environment-setup) first to set up your local environment.

To install the dev dependencies, run:
* `poetry install --with qa`

To lint the code, and check for format and type issues, execute:
* `make check`

To apply the safe lint fixes, and format fixes, execute:
* `make qa`

To apply the safe lint fixes, execute:
* `ruff check --fix`
To run unit tests, execute:
* `make test`

To format the code, execute:
* `ruff format`
To run all checks and tests in a clean environment, similar to the Ci workflow, execute:
* `make ci`

### Building

Expand Down
Loading

0 comments on commit dda6271

Please sign in to comment.