Skip to content

Commit 049ced5

Browse files
authored
Merge pull request #1 from ONS-Innovation/initial-repo-setup
Initial Repository Setup
2 parents 0ba19f0 + ad668fb commit 049ced5

18 files changed

Lines changed: 1658 additions & 2 deletions

.editorconfig

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# http://editorconfig.org
2+
3+
# A special property that should be specified at the top of the file outside of
4+
# any sections. Set to true to stop .editor config file search on current file
5+
root = true
6+
7+
[*]
8+
# Indentation style
9+
# Possible values - tab, space
10+
indent_style = space
11+
12+
# Character length allowed
13+
max_line_length = 120
14+
15+
# Indentation size in single-spaced characters
16+
# Possible values - an integer, tab
17+
indent_size = 4
18+
19+
# Line ending file format
20+
# Possible values - lf, crlf, cr
21+
end_of_line = lf
22+
23+
# File character encoding
24+
# Possible values - latin1, utf-8, utf-16be, utf-16le
25+
charset = utf-8
26+
27+
# Denotes whether to trim whitespace at the end of lines
28+
# Possible values - true, false
29+
trim_trailing_whitespace = true
30+
31+
# Denotes whether file should end with a newline
32+
# Possible values - true, false
33+
insert_final_newline = true
34+
35+
[*.{js,html,json,yaml,yml}]
36+
indent_size = 2
37+
38+
[*.{json,yaml,yml}]
39+
max_line_length = 160
40+
41+
[Makefile]
42+
indent_style = tab

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@ONS-Innovation/keh-dev

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: CI
3+
4+
on: # yamllint disable-line rule:truthy
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
10+
permissions: read-all
11+
12+
concurrency:
13+
group: "${{ github.head_ref || github.ref }}-${{ github.workflow }}"
14+
cancel-in-progress: true
15+
16+
jobs:
17+
lint-test:
18+
name: Lint and Test
19+
runs-on: ubuntu-22.04
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Install Poetry
23+
run: pipx install poetry==1.8.3
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version-file: .python-version
29+
cache: poetry
30+
31+
- name: Install dependencies
32+
run: make install-dev
33+
34+
- name: Lint Python
35+
run: make lint
36+
37+
- name: Test
38+
run: make test

.github/workflows/mega-linter.yml

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
# MegaLinter GitHub Action configuration file
2+
# More info at https://megalinter.io
3+
---
4+
name: MegaLinter
5+
6+
# Trigger mega-linter at every push. Action will also be visible from
7+
# Pull Requests to main
8+
on: # yamllint disable-line rule:truthy
9+
push:
10+
branches: [main]
11+
pull_request:
12+
branches: [main]
13+
14+
permissions: read-all
15+
16+
# Comment env block if you do not want to apply fixes
17+
env:
18+
# Apply linter fixes configuration
19+
#
20+
# When active, APPLY_FIXES must also be defined as environment variable
21+
# (in github/workflows/mega-linter.yml or other CI tool)
22+
# This is dynamically set based on the presence of the PAT secret.
23+
# If the PAT secret is not present, the APPLY_FIXES environment variable is set to none.
24+
# Without a PAT token, commits/PRs will not trigger workflow runs.
25+
# This is a GitHub Actions limitation to prevent infinite loops.
26+
APPLY_FIXES: all
27+
28+
# Decide which event triggers application of fixes in a commit or a PR
29+
# (pull_request, push, all)
30+
APPLY_FIXES_EVENT: pull_request
31+
32+
# If APPLY_FIXES is used, defines if the fixes are directly committed (commit)
33+
# or posted in a PR (pull_request)
34+
APPLY_FIXES_MODE: commit
35+
36+
# Show individual linter status in GitHub Actions status summary
37+
GITHUB_STATUS_REPORTER: true
38+
39+
# Enable to show lint results in GitHub PR comments.
40+
GITHUB_COMMENT_REPORTER: true
41+
42+
# Set to simple to avoid external images in generated markdown
43+
REPORTERS_MARKDOWN_TYPE: simple
44+
45+
concurrency:
46+
group: "${{ github.head_ref || github.ref }}-${{ github.workflow }}"
47+
cancel-in-progress: true
48+
49+
jobs:
50+
lint:
51+
name: MegaLinter
52+
runs-on: ubuntu-latest
53+
54+
# Give the default GITHUB_TOKEN write permission to commit and push, comment
55+
# issues, and post new Pull Requests; remove the ones you do not need
56+
permissions:
57+
contents: write
58+
issues: write
59+
pull-requests: write
60+
statuses: write
61+
62+
steps:
63+
# Git Checkout
64+
- name: Checkout Code
65+
uses: actions/checkout@v4
66+
with:
67+
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
68+
69+
# If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to
70+
# improve performance
71+
fetch-depth: 0
72+
73+
- name: Check PAT and Set APPLY_FIXES
74+
run: |
75+
if [ -z "${{ secrets.PAT }}" ]; then
76+
echo "APPLY_FIXES=none" >> "$GITHUB_ENV"
77+
fi
78+
79+
# MegaLinter
80+
- name: MegaLinter
81+
82+
# You can override MegaLinter flavor used to have faster performances
83+
# More info at https://megalinter.io/latest/flavors/
84+
uses: oxsecurity/megalinter@1fc052d03c7a43c78fe0fee19c9d648b749e0c01
85+
86+
id: ml
87+
88+
# All available variables are described in documentation
89+
# https://megalinter.io/latest/config-file/
90+
env:
91+
# Validates all source when push on main, else just the git diff with
92+
# main. Override with true if you always want to lint all sources
93+
#
94+
# To validate the entire codebase, set to:
95+
# VALIDATE_ALL_CODEBASE: true
96+
#
97+
# To validate only diff with main, set to:
98+
# VALIDATE_ALL_CODEBASE: >-
99+
# ${{
100+
# github.event_name == 'push' &&
101+
# github.ref == 'refs/heads/main'
102+
# }}
103+
VALIDATE_ALL_CODEBASE: true
104+
105+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106+
107+
# ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF
108+
# .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
109+
110+
# Upload MegaLinter artifacts
111+
- name: Archive production artifacts
112+
uses: actions/upload-artifact@v4
113+
if: success() || failure()
114+
with:
115+
name: MegaLinter reports
116+
path: |
117+
megalinter-reports
118+
mega-linter.log
119+
120+
# Create pull request if applicable
121+
# (for now works only on PR from same repository, not from forks)
122+
- name: Create Pull Request with applied fixes
123+
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f
124+
id: cpr
125+
if: >-
126+
steps.ml.outputs.has_updated_sources == 1 &&
127+
(
128+
env.APPLY_FIXES_EVENT == 'all' ||
129+
env.APPLY_FIXES_EVENT == github.event_name
130+
) &&
131+
env.APPLY_FIXES_MODE == 'pull_request' &&
132+
(
133+
github.event_name == 'push' ||
134+
github.event.pull_request.head.repo.full_name == github.repository
135+
) &&
136+
!contains(github.event.head_commit.message, 'skip fix')
137+
with:
138+
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
139+
commit-message: "[MegaLinter] Apply linters automatic fixes"
140+
title: "[MegaLinter] Apply linters automatic fixes"
141+
labels: bot
142+
143+
- name: Create PR output
144+
if: >-
145+
steps.ml.outputs.has_updated_sources == 1 &&
146+
(
147+
env.APPLY_FIXES_EVENT == 'all' ||
148+
env.APPLY_FIXES_EVENT == github.event_name
149+
) &&
150+
env.APPLY_FIXES_MODE == 'pull_request' &&
151+
(
152+
github.event_name == 'push' ||
153+
github.event.pull_request.head.repo.full_name == github.repository
154+
) &&
155+
!contains(github.event.head_commit.message, 'skip fix')
156+
run: |
157+
echo "PR Number - ${{ steps.cpr.outputs.pull-request-number }}"
158+
echo "PR URL - ${{ steps.cpr.outputs.pull-request-url }}"
159+
160+
# Push new commit if applicable
161+
# (for now works only on PR from same repository, not from forks)
162+
- name: Prepare commit
163+
if: >-
164+
steps.ml.outputs.has_updated_sources == 1 &&
165+
(
166+
env.APPLY_FIXES_EVENT == 'all' ||
167+
env.APPLY_FIXES_EVENT == github.event_name
168+
) &&
169+
env.APPLY_FIXES_MODE == 'commit' &&
170+
github.ref != 'refs/heads/main' &&
171+
(
172+
github.event_name == 'push' ||
173+
github.event.pull_request.head.repo.full_name == github.repository
174+
) &&
175+
!contains(github.event.head_commit.message, 'skip fix')
176+
run: sudo chown -Rc $UID .git/
177+
178+
- name: Commit and push applied linter fixes
179+
uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842
180+
if: >-
181+
steps.ml.outputs.has_updated_sources == 1 &&
182+
(
183+
env.APPLY_FIXES_EVENT == 'all' ||
184+
env.APPLY_FIXES_EVENT == github.event_name
185+
) &&
186+
env.APPLY_FIXES_MODE == 'commit' &&
187+
github.ref != 'refs/heads/main' &&
188+
(
189+
github.event_name == 'push' ||
190+
github.event.pull_request.head.repo.full_name == github.repository
191+
) &&
192+
!contains(github.event.head_commit.message, 'skip fix')
193+
with:
194+
branch: >-
195+
${{
196+
github.event.pull_request.head.ref ||
197+
github.head_ref ||
198+
github.ref
199+
}}
200+
commit_message: "[MegaLinter] Apply linters fixes"

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,12 @@ cython_debug/
159159
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160160
# and can be added to the global gitignore or merged into this file. For a more nuclear
161161
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162-
#.idea/
162+
.idea/
163+
164+
# Ruff
165+
.ruff_cache/
166+
167+
megalinter-reports/
168+
169+
# DS_Store files
170+
.DS_Store

.markdownlint.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "MD013": false }

.mega-linter.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
# Configuration file for MegaLinter
3+
#
4+
# See all available variables at https://megalinter.io/latest/config-file/ and in
5+
# linters documentation
6+
7+
# all, none, or list of linter keys
8+
APPLY_FIXES: all
9+
10+
FORMATTERS_DISABLE_ERRORS: false
11+
12+
# If you use ENABLE variable, all other languages/formats/tooling-formats will
13+
# be disabled by default
14+
# ENABLE:
15+
16+
# If you use ENABLE_LINTERS variable, all other linters will be disabled by
17+
# default
18+
# ENABLE_LINTERS:
19+
20+
DISABLE:
21+
- COPYPASTE
22+
- PYTHON
23+
- EDITORCONFIG
24+
- SPELL
25+
26+
DISABLE_LINTERS:
27+
- REPOSITORY_DEVSKIM
28+
- REPOSITORY_TRUFFLEHOG
29+
- REPOSITORY_GIT_DIFF
30+
31+
SHOW_ELAPSED_TIME: true
32+
33+
FILEIO_REPORTER: false
34+
# Uncomment if you want MegaLinter to detect errors but not block CI to pass
35+
# DISABLE_ERRORS: true
36+
37+
# Use yml file to allow the use of comments. Megalinter's default is .markdown-lint.json
38+
MARKDOWN_MARKDOWNLINT_CONFIG_FILE: .markdown-lint.yml
39+
40+
YAML_V8R_FILTER_REGEX_EXCLUDE: "dependabot.yml" # Dependabot yaml in SchemaStore is currently not up to date. Dependabot is validated on push by GitHub by default.

0 commit comments

Comments
 (0)