Skip to content

Commit

Permalink
chore: modify module-checks to support Typescript modules (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonLuttenberger authored Feb 28, 2024
1 parent 4b76179 commit 635939c
Show file tree
Hide file tree
Showing 7 changed files with 2,097 additions and 63 deletions.
43 changes: 35 additions & 8 deletions .github/workflows/module-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: Module Checks
on:
push:
branches: ["main"]
paths: ['modules/**']
paths: ['modules/**', '.github/workflows/module-checks.yml']

pull_request:
branches: ["main", "release/*", "stable"]
paths: ['modules/**']
paths: ['modules/**', '.github/workflows/module-checks.yml']

workflow_dispatch:

Expand All @@ -26,8 +26,8 @@ jobs:
id: get-modules
run: |
set -x
# Get all the modules that have the directory "tests"
MODULES=$(find modules -type d -name "tests" | cut -d/ -f 2-3 | uniq)
# Get all the modules that have the file "deployspec.yaml"
MODULES=$(find modules -type f -name "deployspec.yaml" | cut -d/ -f 2-3 | uniq)
# Create our json structure [{"module_name": "..."}]
MODULES_JSON=$(echo "$MODULES" | jq -R -s 'split("\n")' | jq '[ .[] | select(length > 0) ]' | jq 'map({"module_name": .})')
# Export the modules as json to the outputs
Expand All @@ -43,6 +43,7 @@ jobs:
matrix:
modules: ${{ fromJson(needs.get-modules.outputs.matrix) }}
python-version: [3.9]
node-version: [18.x]
runs-on: ubuntu-latest
env:
MODULE_PATH: 'modules/${{ matrix.modules.module_name }}'
Expand All @@ -51,17 +52,43 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
- id: determine-language
name: Determine Language
run: |
set -x
if [ -f $MODULE_PATH/package.json ]; then \
echo "language=typescript" >> "$GITHUB_OUTPUT"; \
elif [ -f $MODULE_PATH/requirements.txt ]; then \
echo "language=python" >> "$GITHUB_OUTPUT"; \
elif [ -f $MODULE_PATH/pyproject.toml ]; then \
echo "language=python" >> "$GITHUB_OUTPUT"; \
fi
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Requirements
- name: Set up Node ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install Requirements (Python)
if: ${{ steps.determine-language.outputs.language == 'python' }}
run: |
set -x
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install -r $MODULE_PATH/requirements.txt
- name: Static checks and linting (mypy, flake8, black, isort)
run: scripts/validate.sh --language python --path $MODULE_PATH/
- name: Install Requirements (Typescript)
if: ${{ steps.determine-language.outputs.language == 'typescript' }}
run: |
set -x
cd $MODULE_PATH
npm install
- name: Static checks and linting
run: scripts/validate.sh --language ${{ steps.determine-language.outputs.language }} --path $MODULE_PATH/
- name: Pytest
run: cd $MODULE_PATH/ && pytest
if: ${{ steps.determine-language.outputs.language == 'python' }}
run: cd $MODULE_PATH/ && pytest
- name: NPM Test
if: ${{ steps.determine-language.outputs.language == 'typescript' }}
run: cd $MODULE_PATH/ && npm test
23 changes: 23 additions & 0 deletions modules/fmops/sagemaker-jumpstart-fm-endpoint/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"env": { "node": true },
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"sourceType": "module"
},
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }],
"@typescript-eslint/ban-ts-comment": "off",
"no-prototype-builtins": "off",
"@typescript-eslint/no-empty-function": "off"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as cdk from "aws-cdk-lib";
import { Construct } from "constructs";
import { Vpc, SecurityGroup } from "aws-cdk-lib/aws-ec2";
import { Effect, ManagedPolicy, PolicyDocument, PolicyStatement, Role, ServicePrincipal } from "aws-cdk-lib/aws-iam";
import { Effect, PolicyDocument, PolicyStatement, Role, ServicePrincipal } from "aws-cdk-lib/aws-iam";
import { CfnModel } from "aws-cdk-lib/aws-sagemaker";
import {
JumpStartModel,
Expand Down
Loading

0 comments on commit 635939c

Please sign in to comment.