Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: modify module-checks to support Typescript modules #15

Merged
merged 9 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

"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
Loading