Skip to content

- added parsing for TraitSet content #98

- added parsing for TraitSet content

- added parsing for TraitSet content #98

Workflow file for this run

name: Node.js CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20] # Specify Node.js 20
# Only run workflow if TypeScript files were modified
outputs:
js_library_rebuilt: ${{ steps.build_check.outputs.ts_files_modified }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2 # Fetch the last two commits to ensure `git diff` works
- name: Check if TypeScript files were modified
id: build_check
run: |
# Get modified files that are in the 'src/' folder and end with '.ts'
MODIFIED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '^src/.*\.ts$' || true)
# Print the modified files for debugging
echo "Modified files:"
echo "$MODIFIED_FILES"
# Check if MODIFIED_FILES has any content
if [[ -n "$MODIFIED_FILES" ]]; then
echo "Typescript files were modified."
echo "::set-output name=ts_files_modified::true"
else
echo "No TypeScript files were modified."
echo "::set-output name=ts_files_modified::false"
fi
- name: Setup Node.js
if: steps.build_check.outputs.ts_files_modified == 'true'
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
if: steps.build_check.outputs.ts_files_modified == 'true'
run: npm install
- name: Compile TypeScript
if: steps.build_check.outputs.ts_files_modified == 'true'
run: npx tsc
- name: Run tests
if: steps.build_check.outputs.ts_files_modified == 'true'
run: npm test
- name: Upload artifacts
if: steps.build_check.outputs.ts_files_modified == 'true'
uses: actions/upload-artifact@v3
with:
name: dist
path: ./dist
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2 # Fetch the last two commits to ensure `git diff` works
- name: Get modified proc and func sql files
id: get_changed_files
run: |
# Get modified files that are in the 'scripts/' folder and end with '-func.sql' or '-proc.sql'
MODIFIED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '^scripts/.*\(-func\.sql\|-proc\.sql\)$' || true)
# Output the filtered list of modified files
echo "$MODIFIED_FILES" > modified_files.txt
# Check if the modified_files.txt has any content
if [[ -s modified_files.txt ]]; then
echo "::set-output name=modified_files_exist::true"
else
echo "::set-output name=modified_files_exist::false"
fi
# Print the modified files for debugging purposes
echo "Modified files:"
cat modified_files.txt
- name: Download artifacts
if: needs.build.outputs.js_library_rebuilt == 'true'
uses: actions/download-artifact@v3
with:
name: dist
path: ./dist # Make sure the files are downloaded into the correct path
- name: Authenticate to Google Cloud for clingen-swc
if: (needs.build.outputs.js_library_rebuilt == 'true') || (steps.get_changed_files.outputs.modified_files_exist == 'true')
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Setup Google Cloud SDK
if: (needs.build.outputs.js_library_rebuilt == 'true') || (steps.get_changed_files.outputs.modified_files_exist == 'true')
uses: google-github-actions/setup-gcloud@v1
with:
version: 'latest'
- name: Copy javascript libraries to Google Cloud Storage
if: needs.build.outputs.js_library_rebuilt == 'true'
run: |
if [ -z "$(ls -A ./dist)" ]; then
echo "No files found in ./dist, skipping upload."
exit 0
else
echo "Files found, proceeding with upload."
gsutil cp -r ./dist/* gs://clinvar-ingest/bq-tools
fi
- name: Execute clingen-stage modified sql Scripts
if: steps.get_changed_files.outputs.modified_files_exist == 'true'
run: |
echo "Executing sql scripts for clingen-stage in alphabetical order..."
for file in $(find ./scripts -type f -name '*.sql' | sort); do
relative_file=$(realpath --relative-to=. "$file") # Get relative path of the file
if grep -q "$relative_file" modified_files.txt; then
echo "Executing $file..."
bq query --use_legacy_sql=false --project_id=$PROJECT_ID < "$file"
else
echo "Skipping $file as it was not modified."
fi
done
env:
PROJECT_ID: 'clingen-stage'
- name: Execute clingen-dev modified sql Scripts
if: steps.get_changed_files.outputs.modified_files_exist == 'true'
run: |
echo "Executing sql scripts for clingen-dev in alphabetical order..."
for file in $(find ./scripts -type f -name '*.sql' | sort); do
relative_file=$(realpath --relative-to=. "$file") # Get relative path of the file
if grep -q "$relative_file" modified_files.txt; then
echo "Executing $file..."
bq query --use_legacy_sql=false --project_id=$PROJECT_ID < "$file"
else
echo "Skipping $file as it was not modified."
fi
done
env:
PROJECT_ID: 'clingen-dev'