From 9d019fcc70249834cd6c0d52d30cd3ef84281274 Mon Sep 17 00:00:00 2001 From: Nick Jackson Date: Fri, 13 Oct 2023 22:48:34 +0100 Subject: [PATCH] Add prettier to pre-commit and run --- .github/workflows/codeql.yml | 63 ++++++++------- .pre-commit-config.yaml | 6 ++ README.md | 8 +- .../TRE-TDR-2022-DNWR-metadata.json | 78 +++++++++---------- notify_templates/email/new_judgment.md | 6 +- notify_templates/email/updated_judgment.md | 6 +- 6 files changed, 85 insertions(+), 82 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 4c0083a..6bf8184 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -13,12 +13,12 @@ name: "CodeQL" on: push: - branches: [ "main" ] + branches: ["main"] pull_request: # The branches below must be a subset of the branches above - branches: [ "main" ] + branches: ["main"] schedule: - - cron: '17 10 * * 6' + - cron: "17 10 * * 6" jobs: analyze: @@ -32,43 +32,42 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'python' ] + language: ["python"] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support steps: - - name: Checkout repository - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3874397..247a4c8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,3 +30,9 @@ repos: hooks: - id: mypy files: ^ds-caselaw-ingester/ + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v2.7.1 + hooks: + - id: prettier + types_or: [yaml, json, markdown] diff --git a/README.md b/README.md index dfc6ffd..2d95a7b 100644 --- a/README.md +++ b/README.md @@ -68,10 +68,10 @@ The logs will show the response from the lambda directly below this line. Any va To run the tests -* [First time] create a virtualenv (`virtualenv venv -p \`which python\`` ) -* Activate it with `. venv/bin/activate` -* `scripts/test` -* When you're done, you might want to `deactivate` +- [First time] create a virtualenv (`virtualenv venv -p \`which python\`` ) +- Activate it with `. venv/bin/activate` +- `scripts/test` +- When you're done, you might want to `deactivate` Note that you might get a spurious errors about django config and environment variables if you're running in the wrong environment. diff --git a/aws_examples/s3/te-editorial-out-int/TRE-TDR-2022-DNWR-metadata.json b/aws_examples/s3/te-editorial-out-int/TRE-TDR-2022-DNWR-metadata.json index 687eddb..146272b 100644 --- a/aws_examples/s3/te-editorial-out-int/TRE-TDR-2022-DNWR-metadata.json +++ b/aws_examples/s3/te-editorial-out-int/TRE-TDR-2022-DNWR-metadata.json @@ -1,44 +1,42 @@ { - "producer": { - "name": "TRE", - "process": "transform", - "type": "judgment" + "producer": { + "name": "TRE", + "process": "transform", + "type": "judgment" + }, + "parameters": { + "TRE": { + "reference": "TRE-TDR-2022-DNWR", + "payload": { + "filename": "test.docx", + "xml": "TDR-2022-DNWR.xml", + "metadata": "TRE-TDR-2022-DNWR-metadata.json", + "images": ["image1.png"], + "log": "parser.log" + } }, - "parameters": { - "TRE": { - "reference": "TRE-TDR-2022-DNWR", - "payload": { - "filename": "test.docx", - "xml": "TDR-2022-DNWR.xml", - "metadata": "TRE-TDR-2022-DNWR-metadata.json", - "images": [ - "image1.png" - ], - "log": "parser.log" - } - }, - "PARSER": { - "uri": "https://caselaw.nationalarchives.gov.uk/id/ewca/civ/2022/111", - "court": "EWCA-Civil", - "cite": "[2022] EWCA Civ 111", - "date": "2022-01-01", - "name": "X v Y", - "attachments": [], - "error-messages": [] - }, - "TDR": { - "Consignment-Type": "judgment", - "Bag-Creator": "TDRExportv0.0.29", - "Consignment-Start-Datetime": "2021-12-16T14:51:49Z", - "Consignment-Series": "", - "Source-Organization": "Ministry of Justice", - "Contact-Name": "Tom King", - "Internal-Sender-Identifier": "TDR-2021-CF6L", - "Consignment-Completed-Datetime": "2021-12-16T14:54:06Z", - "Consignment-Export-Datetime": "2021-12-16T14:54:55Z", - "Contact-Email": "someone@example.com", - "Payload-Oxum": "45956.1", - "Bagging-Date": "2021-12-16" - } + "PARSER": { + "uri": "https://caselaw.nationalarchives.gov.uk/id/ewca/civ/2022/111", + "court": "EWCA-Civil", + "cite": "[2022] EWCA Civ 111", + "date": "2022-01-01", + "name": "X v Y", + "attachments": [], + "error-messages": [] + }, + "TDR": { + "Consignment-Type": "judgment", + "Bag-Creator": "TDRExportv0.0.29", + "Consignment-Start-Datetime": "2021-12-16T14:51:49Z", + "Consignment-Series": "", + "Source-Organization": "Ministry of Justice", + "Contact-Name": "Tom King", + "Internal-Sender-Identifier": "TDR-2021-CF6L", + "Consignment-Completed-Datetime": "2021-12-16T14:54:06Z", + "Consignment-Export-Datetime": "2021-12-16T14:54:55Z", + "Contact-Email": "someone@example.com", + "Payload-Oxum": "45956.1", + "Bagging-Date": "2021-12-16" } + } } diff --git a/notify_templates/email/new_judgment.md b/notify_templates/email/new_judgment.md index 944f456..b2e3627 100644 --- a/notify_templates/email/new_judgment.md +++ b/notify_templates/email/new_judgment.md @@ -1,5 +1,5 @@ A new judgment has been submitted for review; see ((url)) -* TDR Consignment Number: ((consignment)) -* Submitter: ((submitter)) -* Submitted at: ((submitted_at)) +- TDR Consignment Number: ((consignment)) +- Submitter: ((submitter)) +- Submitted at: ((submitted_at)) diff --git a/notify_templates/email/updated_judgment.md b/notify_templates/email/updated_judgment.md index 2ab08b1..b549c83 100644 --- a/notify_templates/email/updated_judgment.md +++ b/notify_templates/email/updated_judgment.md @@ -1,5 +1,5 @@ A new version of the judgment at ((url)) has been submitted! -* TDR Consignment Number: ((consignment)) -* Submitter: ((submitter)) -* Submitted at: ((submitted_at)) +- TDR Consignment Number: ((consignment)) +- Submitter: ((submitter)) +- Submitted at: ((submitted_at))