Skip to content

Commit

Permalink
ci: Added validate MD github action (#823)
Browse files Browse the repository at this point in the history
* ci: Added validate MD github action

Added github action which validates the module descriptor (WIP)

* ci: Tweaked action

Setup maven step wasn't right

* ci: Whoops, need to include service directory

* ci: Github action path?

* ci: Remember to checkout repository

* ci: Use java 17 explicitly?

* ci: *sigh* point at right module descriptor file

* ci: Tweak name to leave room for future validations maybe

* ci: Rename file

* ci: Set up settings file as part of action

* ci: Testing commenting the failures on the PR

* ci: Tweak output name

* ci: Testing validator errors to file

* ci: On failure grab file contents, make sure it's only the errors (Using grep, bit messy)

* ci: Whoopsie in github comment step

* ci: Another tweak

* ci: Send txt file in curl directly?

* ci: Comment out maybe-failing line

* ci: Stop using deprecated set-ouput based action

* ci: Trying RAW string literal

* ci: Trying --data instead of -d

* ci: Change back to escaped body, but hopefully send as plain text

* ci: Whoopsie

* ci: Triple escape file

* ci: Remove now unnecessary comment

* ci: Syntax is hard

* ci: At least log to actions run file

* ci: Testing comment

* ci: Testing2

* ci: I'm an idiot

* ci: Can we get pull request number

* ci: Move get PR number after checkout

* ci: Send file as raw data?

* ci: De-raw the data

* ci: JQ json-safety

* ci: Save in single string (and hope github comment can parse it out again

* ci: Send whole error file as single JSON line

* ci: Finally will this send??

* ci: Cleanup output comment

* ci: Slightly more cleanup

* build: Turn off validate temporarily so we can merge the workflow PR and spin off a neater PR with actual perm changes
  • Loading branch information
EthanFreestone authored Sep 25, 2024
1 parent 28d8d4c commit daf3bcd
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/validate-module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# name: Validate module

# on:
# push:

# jobs:
# run:
# name: Validate module descriptor
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Get Pull Request Number
# id: pr_number
# run: echo "pull_request_number=$(gh pr view --json number -q .number || echo "")" >> $GITHUB_OUTPUT
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Setup java
# uses: actions/setup-java@v4
# with:
# distribution: 'temurin' # See 'Supported distributions' for available options
# java-version: '17'
# - name: Set up Maven
# uses: stCarolas/setup-maven@v5
# with:
# maven-version: 3.8.2
# - name: Set up settings file
# uses: 1arp/[email protected]
# with:
# path: 'service'
# file: 'settings.xml'
# content:
# <settings>
# <profiles>
# <profile>
# <id>folioMavenProfile</id>
# <pluginRepositories>
# <pluginRepository>
# <id>folio-nexus</id>
# <name>FOLIO Maven repository</name>
# <url>https://repository.folio.org/repository/maven-folio</url>
# </pluginRepository>
# </pluginRepositories>
# </profile>
# </profiles>
# <activeProfiles>
# <activeProfile>folioMavenProfile</activeProfile>
# </activeProfiles>
# </settings>
# - name: Run validator
# run: mvn org.folio:folio-module-descriptor-validator:1.0.0:validate -DmoduleDescriptorFile=service/src/main/okapi/ModuleDescriptor-template.json -s service/settings.xml -l validate_module_descriptor_output.txt
# - name: Upload validator result
# uses: actions/upload-artifact@v4
# if: always()
# with:
# name: validate_module_descriptor_output
# path: |
# validate_module_descriptor_output.txt
# retention-days: 1
# - name: Setup validate_module_descriptor_errors file
# if: failure()
# run: echo "$(cat validate_module_descriptor_output.txt)" | egrep "\[ERROR\]\s*(\"key\"|\"value\")" | sed 's/\[ERROR\]\(\s*\)//;s/\"value\"\(\s*\):\(\s*\)\(.*\)/\3\n/;s/"key\"\(\s*\):\(\s*\)\(.*\)/\3/' | tee validate_module_descriptor_errors.txt
# - name: Comment failures on PR
# if: failure()
# run: |
# # Use GitHub API to create a comment on the PR
# PR_NUMBER=${{ steps.pr_number.outputs.pull_request_number }}
# GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
# COMMENT_URL="https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments"
# echo "SENDING TO: $COMMENT_URL"
# curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST $COMMENT_URL --data "{ \"body\": $(cat validate_module_descriptor_errors.txt | jq -Rs) }"

0 comments on commit daf3bcd

Please sign in to comment.