-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from nationalarchives/proof-of-concept
Initial merge
- Loading branch information
Showing
147 changed files
with
16,678 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"sourceType": "unambiguous", | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"chrome": 114 | ||
} | ||
} | ||
] | ||
], | ||
"plugins": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.dockerignore | ||
.git | ||
docker-compose.yml | ||
Dockerfile | ||
README.md | ||
node_modules | ||
tmp | ||
.babelrc.json | ||
.eslintrc.js | ||
.flake8 | ||
.gitignore | ||
.stylelintrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
if [ -n "$POETRY_VERSION" ]; then | ||
export PATH="/app/.local/bin:$PATH" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es2021: true, | ||
}, | ||
extends: ["eslint:recommended"], | ||
overrides: [ | ||
{ | ||
env: { | ||
node: true, | ||
}, | ||
files: [".eslintrc.{js,cjs}"], | ||
parserOptions: { | ||
sourceType: "script", | ||
}, | ||
}, | ||
], | ||
parserOptions: { | ||
ecmaVersion: "latest", | ||
sourceType: "module", | ||
}, | ||
rules: {}, | ||
ignorePatterns: ["webpack.config.js", "*.min.js", "tmp/*"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[flake8] | ||
ignore = E203, E266, E501, W503, F403, F401 | ||
exclude = venv*,__pycache__,node_modules,migrations,tmp | ||
max-line-length = 80 | ||
max-complexity = 12 | ||
select = B,C,E,F,W,T4,B9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: Run Node tests | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Install Node dependencies | ||
run: npm install | ||
shell: bash | ||
- name: Run Node tests | ||
run: npm run test:all | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Run Python tests | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.12 | ||
- uses: snok/install-poetry@v1 | ||
with: | ||
version: 1.8.1 | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
virtualenvs-path: .venv | ||
- name: Install Poetry dependencies | ||
run: poetry install --no-interaction --no-root | ||
shell: bash | ||
- name: Make tmp directory | ||
run: mkdir tmp | ||
shell: bash | ||
- name: Clone ds-wagtail | ||
run: cd tmp && git clone https://github.com/nationalarchives/ds-wagtail.git ds-wagtail | ||
shell: bash | ||
- name: Run Python tests | ||
run: poetry run python -m pytest | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Clean up feature branch | ||
|
||
on: | ||
delete: | ||
|
||
jobs: | ||
delete: | ||
if: github.event.ref_type == 'branch' && startsWith(github.event.ref, 'feature/') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Get tag from deleted branch | ||
id: version-tag | ||
run: echo "VERSION=$(echo "${{ github.event.ref }}" | sed -e 's,/,-,g')" >> "$GITHUB_OUTPUT" | ||
- name: Debug | ||
run: echo "Clean up Docker image ${{ vars.DOCKER_IMAGE_NAME }}:${{ steps.version-tag.outputs.VERSION }}" | ||
- name: Delete image | ||
if: ${{ steps.version-tag.outputs.VERSION }} | ||
uses: bots-house/[email protected] | ||
with: | ||
owner: ${{ github.repository_owner }} | ||
name: ${{ vars.DOCKER_IMAGE_NAME }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
tag: ${{ steps.version-tag.outputs.VERSION }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Build and deploy | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
|
||
concurrency: | ||
group: cd-${{ github.ref }} | ||
|
||
jobs: | ||
test-node: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run tests | ||
uses: ./.github/actions/node-tests | ||
|
||
test-python: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run tests | ||
uses: ./.github/actions/python-tests | ||
|
||
version: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Get tag | ||
id: version-tag | ||
uses: nationalarchives/ds-docker-actions/.github/actions/get-version-tag@main | ||
outputs: | ||
version: ${{ steps.version-tag.outputs.version-tag }} | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- test-python | ||
- test-node | ||
- version | ||
permissions: | ||
packages: write | ||
contents: read | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build Docker image | ||
uses: nationalarchives/ds-docker-actions/.github/actions/docker-build@main | ||
with: | ||
version: ${{ needs.version.outputs.version }} | ||
latest: ${{ github.ref == 'refs/heads/main' }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
docker-image-name: ${{ vars.DOCKER_IMAGE_NAME }} | ||
|
||
update: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
- version | ||
if: github.ref == 'refs/heads/main' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
repository: nationalarchives/ds-etna-deployments-proof-of-concept | ||
ref: main | ||
token: ${{ secrets.ACTIONS_GITHUB_TOKEN }} | ||
- name: Set up git config | ||
run: | | ||
git config user.name "ds-etna-frontend" | ||
git config user.email "<>" | ||
- name: Install jq | ||
run: sudo apt-get install jq | ||
- name: Update config | ||
run: jq --indent 4 '(.services.frontend.version|="${{ needs.version.outputs.version }}")' config-aws-develop.json > tmp.$$.json && mv tmp.$$.json config-aws-develop.json | ||
- name: Push new version | ||
run: | | ||
git add config-aws-develop.json | ||
git commit -m "Update frontend to v${{ needs.version.outputs.version }}" | ||
git push origin main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Pull request | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
|
||
jobs: | ||
test-node: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run tests | ||
uses: ./.github/actions/node-tests | ||
|
||
test-python: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run tests | ||
uses: ./.github/actions/python-tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Remove untagged container images | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "0 3 * * 1" | ||
|
||
jobs: | ||
remove-untagged: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Remove untagged Docker images | ||
uses: nationalarchives/ds-docker-actions/.github/actions/remove-untagged@main | ||
with: | ||
docker-image-name: ${{ vars.DOCKER_IMAGE_NAME }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.DS_Store | ||
__pycache__ | ||
/node_modules | ||
/app/static/assets | ||
/app/static/*.css | ||
/app/static/*.css.map | ||
/app/static/*.min.js | ||
/app/static/*.min.js.map | ||
/tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lts/iron |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: app | ||
|
||
type: "python:3.11" | ||
|
||
variables: | ||
env: | ||
ENVIRONMENT: production | ||
POETRY_VERSION: "1.6.1" | ||
POETRY_VIRTUALENVS_IN_PROJECT: true | ||
POETRY_VIRTUALENVS_CREATE: true | ||
PIP_DISABLE_PIP_VERSION_CHECK: true | ||
|
||
disk: 2048 | ||
|
||
hooks: | ||
build: | | ||
set -eu | ||
python3.11 -m pip install --upgrade pip | ||
export PIP_USER=false | ||
curl -sSL https://install.python-poetry.org | python3 - --version $POETRY_VERSION | ||
export PATH="/app/.local/bin:$PATH" | ||
export PIP_USER=true | ||
poetry install | ||
poetry add [email protected] | ||
npm install | ||
npm run build | ||
mkdir app/static/assets | ||
cp -r node_modules/@nationalarchives/frontend/nationalarchives/assets/* app/static/assets | ||
web: | ||
upstream: | ||
socket_family: unix | ||
commands: | ||
start: "poetry run gunicorn etna:app --bind unix:$SOCKET --capture-output --log-file /var/log/app.log --log-level debug" | ||
locations: | ||
"/": | ||
root: "" | ||
passthru: true | ||
allow: false | ||
"/static": | ||
headers: | ||
Access-Control-Allow-Origin: "*" | ||
root: static | ||
expires: 1y | ||
allow: true | ||
|
||
mounts: | ||
tmp: | ||
source: local | ||
source_path: tmp | ||
|
||
crons: | ||
renewcert: | ||
spec: "0 4 1,15 * *" | ||
cmd: | | ||
if [ "$PLATFORM_BRANCH" = main ]; then | ||
platform redeploy --yes --no-wait | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
**/*.html | ||
tmp/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": ["stylelint-config-standard-scss"], | ||
"plugins": ["stylelint-selector-bem-pattern"], | ||
"rules": { | ||
"at-rule-empty-line-before": null, | ||
"block-no-empty": null, | ||
"declaration-empty-line-before": null, | ||
"property-no-vendor-prefix": null, | ||
"value-keyword-case": null, | ||
"scss/dollar-variable-empty-line-before": null, | ||
"scss/double-slash-comment-empty-line-before": null, | ||
"selector-class-pattern": null, | ||
"plugin/selector-bem-pattern": { | ||
"preset": "bem" | ||
} | ||
}, | ||
"ignoreFiles": ["app/**/*.css", "tmp/**/*.css", "tmp/**/*.scss"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
ARG IMAGE=ghcr.io/nationalarchives/tna-python | ||
ARG IMAGE_TAG=latest | ||
|
||
FROM "$IMAGE":"$IMAGE_TAG" | ||
|
||
ENV NPM_BUILD_COMMAND=compile | ||
|
||
# Copy in the application code | ||
COPY --chown=app . . | ||
|
||
# Install dependencies | ||
RUN tna-build | ||
|
||
# Copy in the static assets from TNA Frontend | ||
RUN mkdir /app/app/static/assets; \ | ||
cp -r /app/node_modules/@nationalarchives/frontend/nationalarchives/assets/* /app/app/static/assets | ||
|
||
# Delete source files and tests | ||
RUN rm -fR /app/src /app/test | ||
|
||
# Run the application | ||
CMD ["tna-run", "etna:app"] |
Oops, something went wrong.