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
5 changes: 1 addition & 4 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# Uncomment the appropriate line

# @ONSdigital/keh-dev
@ONS-Innovation/keh-dev
@ONS-Innovation/keh-dev
21 changes: 18 additions & 3 deletions .github/workflows/ci-fmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ jobs:
permissions:
contents: read
steps:
- name: Implement linting and formatting checks (TODO)
run: |-
echo "TODO: Implement linting and formatting checks"
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # V4.3.1
with:
persist-credentials: false
- name: Install Poetry
run: |
pipx install poetry
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # V5.6.0
with:
python-version-file: ".python-version"
cache: poetry
- name: Install dependencies
run: |
make install-dev
- name: Run linters
run: |
make lint
27 changes: 16 additions & 11 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,21 @@ jobs:
permissions:
contents: read
steps:
- name: Implement unit tests (TODO)
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # V4.3.1
with:
persist-credentials: false
- name: Install Poetry
run: |
echo "TODO: Implement unit tests"
ui-tests:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Implement UI tests (TODO)
pipx install poetry
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # V5.6.0
with:
python-version-file: ".python-version"
cache: poetry
- name: Install dependencies
run: |
make install-dev
- name: Run linters
run: |
echo "TODO: Implement UI tests"

# Add more test jobs as needed, such as integration tests, end-to-end tests, etc.
make test
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,15 @@ megalinter-reports/
.idea
.DS_Store
*.log

# Poetry Build Artifacts
dist/
build/

# Cache files
__pycache__/

# Test and coverage reports
.coverage
htmlcov/
coverage.xml
1 change: 1 addition & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
venv
40 changes: 35 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

##
## -----------------------------------------------
## Makefile for [Project Name]
## Makefile for GitHub Policy Audit.
## -----------------------------------------------
##

Expand All @@ -28,10 +28,21 @@ help: ## This help message.
clean: ## Clean the temporary files.
rm -rf megalinter-reports
rm -rf site
rm -rf dist
rm -rf build
rm -rf .ruff_cache
rm -rf .mypy_cache
rm -rf .pytest_cache
rm -rf .coverage
find . -type d -name '__pycache__' -exec rm -rf {} +

##

# TODO: Add more targets as needed.
.PHONY: install-dev
install-dev: ## Install the development dependencies.
poetry install --with dev

##

# MkDocs

Expand Down Expand Up @@ -63,7 +74,26 @@ docs-fix: ## Install and run the documentation linter with auto-fix (Markdown

# Primary Linting

# TODO: Add the primary linting target here.
.PHONY: lint
lint: ## Run all linters.
poetry run ruff check src tests
poetry run ruff format src tests --check
poetry run mypy src tests

.PHONY: fmt
fmt: ## Run all formatters.
poetry run ruff check src tests --fix
poetry run ruff format src tests

##

# Tests

.PHONY: test
test: ## Run all tests and check coverage.
poetry run pytest -n auto --cov=src --cov-report term-missing --cov-fail-under=80

##

# Megalinter

Expand All @@ -72,6 +102,6 @@ megalinter: ## Run the Megalinter.
docker run --platform linux/amd64 --rm \
-v /var/run/docker.sock:/var/run/docker.sock:rw \
-v $(shell pwd):/tmp/lint:rw \
oxsecurity/megalinter:v9
ghcr.io/oxsecurity/megalinter:v9

##
##
91 changes: 39 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,32 @@
# KEH Template Repository
# GitHub Policy Audit

This repository is a template for all new Knowledge Exchange Hub (KEH) repositories. It contains the basic structure and files that are common to all KEH repositories, such as CODEOWNERS, sample GitHub Actions workflows, and a README template.

## Usage

### Creating a New Repository

To use this template when creating a new repository, simply select "Use this template" on GitHub and follow the prompts to create your new repository based on this template. This will ensure that your new repository has the necessary structure and files to maintain consistency across all KEH repositories.

### Further Setup

Since this repository is intended for all KEH repositories, it needs some additional setup once you have created your new repository. The steps below outline the necessary customisation and setup:

1. **Update the README**: Replace the content of the README with information relevant to your project. This should use the template below as a starting point.
2. **Update CODEOWNERS**: Modify the CODEOWNERS file to chose the appropriate team. The 2 options for KEH are within the file itself.
3. **Set up GitHub Actions**: This repository has already setup some sample GitHub Actions workflows (i.e. MkDocs related actions and Megalinter). In addition to this, the repository should also have its primary language linter and test workflow set up. Placeholders for these workflows are already in place, so you just need to fill in the details ([ci-fmt](./.github/workflows/ci-fmt.yml), [ci-test](./.github/workflows/ci-test.yml)). The actions use paths to only run when files in certain directories are changed (e.g. `src` and `tests`), so make sure to update these paths if your repository has a different structure.
4. **Setup Repository Settings**: The repository should have the following settings configured:
1. **Contributors**:
1. Add `keh-dev` to the repository with **Write** access.
2. Add `keh-dev-admin` to the repository with **Admin** access.
2. **Branch Protection Rules**:
1. Within `Rules > Rulesets`, create a new _branch ruleset_ for the `main` branch.
2. Add the following rules to the ruleset:
1. Add `keh-dev-admin` to the Bypass List. This is for emergency situations where you need to bypass branch protection rules.
2. Target the Default Branch (`main`).
3. Restrict deletions.
4. Require a pull request before merging. This should require **at least 2 approving reviews**.
5. Block force pushes.
3. Save the ruleset.
5. **Setup Repository for Project Use**: Now that the housekeeping is done, you can set up the repository for project use.

#### Python Specific Setup

When using Python, Poetry has already been setup for dependency management since it is used for documentation.

Ensure that you update the `pyproject.toml` file to match the needs of your project.

## README Template

The below is a template for the README file that should be used for all KEH repositories. This template provides a basic structure and can be customised to fit the specific needs of your project.

Everything above this line should be removed when customising the README for your project.

---

# Project Name <!-- markdownlint-disable-line MD025 -->

<!-- A brief description of the project goes here. -->
A tool used to audit GitHub Organisations for compliance with ONS' GitHub Usage Policy. Built using the [KEH Policy Methods Library](https://github.com/ONS-Innovation/keh-policy-methods-library), this tool produces a report of the audit findings, which can be used to identify areas of non-compliance and inform remediation efforts. Additionally, these reports can track compliance over time, providing a historical record of the organisation's adherence to the policy, and its progress towards achieving compliance.

## Table of Contents

<!-- A table of contents for the README goes here. -->
<!-- This can be automatically generated using a tool like the Markdown All in One extension for Visual Studio Code. -->
- [GitHub Policy Audit](#github-policy-audit)
- [Table of Contents](#table-of-contents)
- [Prerequisites](#prerequisites)
- [Makefile](#makefile)
- [Running the Project](#running-the-project)
- [Deployment](#deployment)
- [Deployments with Concourse](#deployments-with-concourse)
- [Manual Deployment](#manual-deployment)
- [Documentation](#documentation)
- [GitHub Actions for Documentation](#github-actions-for-documentation)
- [Local Development of Documentation](#local-development-of-documentation)
- [Linting and Testing](#linting-and-testing)
- [GitHub Actions](#github-actions)
- [Running Tests and Linters Locally](#running-tests-and-linters-locally)
- [Primary Language](#primary-language)
- [MegaLinter](#megalinter)
- [Documentation linting and building](#documentation-linting-and-building)

## Prerequisites

<!-- A list of prerequisites for the project goes here. -->
- Python 3.12 or higher
- Poetry for dependency management
- Node.js and npm for documentation linting (Markdownlint)

## Makefile

Expand Down Expand Up @@ -131,7 +102,23 @@ This repository has GitHub Actions workflows set up for linting and testing. The

#### Primary Language

<!-- Instructions for running the primary language linter and tests locally go here. This will depend on the primary language of the project. -->
To run the linters and formatters for the primary language (Python) locally, you can use the following command:

```bash
make lint
```

To apply automatic fixes for any linting or formatting issues found, you can use:

```bash
make fmt
```

To run the tests locally, you can use:

```bash
make test-unit
```

#### MegaLinter

Expand Down
2 changes: 0 additions & 2 deletions kics.config

This file was deleted.

Loading
Loading