Skip to content

handling blockType parameter for setblock() command #128

handling blockType parameter for setblock() command

handling blockType parameter for setblock() command #128

Workflow file for this run

name: Parser WebHelp and output npm package contains lua definitions file
on:
pull_request:
types:
- opened
- reopened
- synchronize
- closed
push:
tags:
- "*"
jobs:
webhelp-to-json:
name: webhelp-to-json
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: install node
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://npm.pkg.github.com
- name: Install package from npm registry
run: |
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > .npmrc
npm install
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: install requirements.txt
run: pip install -r requirements.txt
- name: Copy HTML file
run: cp -r node_modules/@tektronix/web-help-documents web-help-documents
- name: Run Python script to generate JSON
run: python main.py web-help-documents
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: generated-json
path: data
json-to-lua:
name: json-to-lua
runs-on: ubuntu-latest
needs:
- webhelp-to-json
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v4
- name: Restore dependencies
run: |
cd Json_parser
dotnet restore
- name: Build the project
run: |
cd Json_parser
dotnet build --configuration Release
- name: Get Artifacts
uses: actions/download-artifact@v4
with:
name: generated-json
path: data/
- name: Run the binary with folder path
run: |
cd Json_parser
dotnet run $GITHUB_WORKSPACE/data/
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: keithley_instrument_libraries
path: ./Json_parser/keithley_instrument_libraries
test:
name: test
runs-on: ubuntu-latest
needs:
- webhelp-to-json
- json-to-lua
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: install node
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://npm.pkg.github.com
- name: Install package from npm registry
run: |
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > .npmrc
npm install
- name: Get Artifacts
uses: actions/download-artifact@v4
with:
name: keithley_instrument_libraries
path: generatedLuaDefinitions/
- name: test
run: npm run call-LuaLS-Diagnostics $GITHUB_WORKSPACE/generatedLuaDefinitions/
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: diagnostics-reports
path: testResults
- name: Set up jq
run: |
sudo apt-get update
sudo apt-get install -y jq
- name: Verify jq installation
run: |
if ! command -v jq &> /dev/null
then
echo "jq could not be found"
exit 1
fi
jq --version
- name: Find and check JSON files
id: check_json
run: |
set -e
set -x
PARENT_DIR="$GITHUB_WORKSPACE/testResults"
FAILED_TESTS=0
PASSED_TESTS=0
RESULT=""
echo "Parent directory: $PARENT_DIR"
for SUBFOLDER in "$PARENT_DIR"/*/; do
echo "Checking subfolder: $SUBFOLDER"
if [ -d "$SUBFOLDER" ]; then
JSON_FILE="${SUBFOLDER}Diagnostics.json"
if [[ -f "$JSON_FILE" ]]; then
echo "Looking for file: $JSON_FILE"
if [[ $(jq 'length' $JSON_FILE) -ne 0 ]]; then
RESULT+="Test failed for subfolder: ${SUBFOLDER}\n"
FAILED_TESTS+=1
else
RESULT+="Test passed for subfolder: ${SUBFOLDER}\n"
PASSED_TESTS+=1
fi
else
RESULT+="No JSON file found in subfolder: ${SUBFOLDER}\n"
fi
else
echo "Not a directory: $SUBFOLDER"
fi
done
echo "result=$RESULT" >> $GITHUB_ENV
echo "failed_tests=$FAILED_TESTS" >> $GITHUB_ENV
echo "passed_tests=$PASSED_TESTS" >> $GITHUB_ENV
- name: Create pull request comment
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const result = process.env.result;
const failedTests = process.env.failed_tests;
const passedTests = process.env.passed_tests;
const message = `## JSON File Check Results\n\n${result}\n**Total Failed Tests:** ${failedTests}\n**Total Passed Tests:** ${passedTests}`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message
});
publish:
name: Publish
if: ${{ endsWith(github.base_ref, 'main') && (contains(github.head_ref, 'release/') || github.event.pull_request.merged) }}
needs:
- webhelp-to-json
- json-to-lua
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: "https://npm.pkg.github.com"
scope: "@tektronix"
- name: Get Artifacts
uses: actions/download-artifact@v4
with:
name: keithley_instrument_libraries
path: keithley_instrument_libraries/
- name: npm Package
run: npm pack
- name: publish package
run: |
npm publish *.tgz
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
checks: write
pull-requests: read
needs:
- webhelp-to-json
- json-to-lua
if: ${{ (endsWith(github.base_ref, 'main') && (contains(github.head_ref, 'release/')) || github.event.pull_request.merged ) }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Get RC Version
id: lasttag
run: |
COMMIT="${{github.sha}}"
if ${{contains(github.head_ref, 'release/')}}; then
V="${{github.head_ref}}"
V="${V#release/}"
else
V="$(npm pkg get version)"
echo "Extracted Version: $V"
V="$(echo v"$V" | sed 's/\"//g')"
echo "Cleaned up Version: $V"
fi
# Check to see if the version tag already exists
# If it does, print a message and exit with an error code
if [ $(git tag --list "$V") ]; then
echo "Version tag already exists. Did you bump the version number?"
exit 1
fi
# Create an RC release if
# 1) This PR is a release branch that hasn't been merged to main.
# 2) This is a feature branch being merged into the main branch.
if ${{(! github.event.pull_request.merged && contains(github.head_ref, 'release/')) || (github.event.pull_request.merged && !contains(github.head_ref, 'release/'))}}; then
V="${V}-$(git tag --list ${V}* | wc -l)"
echo "RC Version: $V"
fi
CL=${V#v}
CL=${CL%-*}
echo "version=${V}" >> $GITHUB_OUTPUT
echo "cl_version=${CL}" >> $GITHUB_OUTPUT
echo "commit=${COMMIT}" >> $GITHUB_OUTPUT
- run: "git tag --list ${V}*"
- name: Get Changelog for this Tag
id: changelog
uses: coditory/changelog-parser@v1
with:
version: ${{steps.lasttag.outputs.cl_version}}
- name: Create Release
uses: ncipollo/release-action@v1
with:
name: ${{steps.lasttag.outputs.version}}
artifacts: "keithley_instrument_libraries,generated-json"
body: |
## Features Requests / Bugs
If you find issues or have a feature request, please enter a [new issue on GitHub](${{github.server_url}}/${{github.repository}}/issues/new).
## Installation
View the installation instructions in the [README](${{github.server_url}}/${{github.repository}}/blob/main/README.md)
## Changelog
${{steps.changelog.outputs.description}}
prerelease: ${{ (! github.event.pull_request.merged) || (github.event.pull_request.merged && ! contains(github.head_ref, 'release/')) }}
commit: ${{steps.lasttag.outputs.commit}}
makeLatest: true
tag: ${{steps.lasttag.outputs.version}}