Skip to content

Commit

Permalink
Element datetime fix (#345)
Browse files Browse the repository at this point in the history
* Modified generate.sh so you can test generation with local files

Fixed issue with sed not working

* Fix issue where some strings were being automatically converted in Symphony Element Forms

* Update to upload-artifact@v4

* Update github actions as v2 is deprecated

* Change to upload-artifact v3

* Update dependencies to fix security vulnerabilities

* Update testing dependencies

* New Lock file

* Updated tests due to issue with aiohttp 3.10.x

* Exclude Vulnerability 70612
  • Loading branch information
anthony-symphony authored Oct 30, 2024
1 parent e31a701 commit 8ef4d50
Show file tree
Hide file tree
Showing 14 changed files with 201 additions and 136 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
path: ~\AppData\Local\pypoetry\Cache\virtualenvs

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -35,7 +35,7 @@ jobs:
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache pip dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ steps.setup-python.outputs.python-version }}
Expand All @@ -44,7 +44,7 @@ jobs:
run: pip install poetry

- name: Cache poetry
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ matrix.path }}
key: ${{ runner.os }}-poetry-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
Expand All @@ -58,14 +58,14 @@ jobs:
timeout-minutes: 10

- name: Upload test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: pytest-results-${{ matrix.os }}
path: test-results/junit.xml
if: ${{ always() }}

- name: Upload test coverage
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: pytest-coverage-${{ matrix.os }}
path: htmlcov
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cve-scanning-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
name: Build and test App
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.10"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/license-scanning-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
name: Scan for licenses
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.10"
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/python@b98d498629f1c368650224d6d212bf7dfa89e4bf
env:
Expand All @@ -20,13 +20,13 @@ jobs:
documentation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python 3.8
id: setup-python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8

Expand All @@ -41,7 +41,7 @@ jobs:
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache pip dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ steps.setup-python.outputs.python-version }}
Expand All @@ -50,7 +50,7 @@ jobs:
run: pip install poetry

- name: Cache poetry
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/pylint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:

steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Python 3.8
id: setup-python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8

Expand All @@ -27,7 +27,7 @@ jobs:
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache pip dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ steps.setup-python.outputs.python-version }}
Expand All @@ -50,7 +50,7 @@ jobs:

- name: Upload Pylint results
if: ${{ always() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: .pylint.d
path: ~/.pylint.d
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python 3.8
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:

steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Python 3.8
id: setup-python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8

Expand All @@ -27,7 +27,7 @@ jobs:
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache pip dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ steps.setup-python.outputs.python-version }}
Expand All @@ -36,7 +36,7 @@ jobs:
run: pip install poetry

- name: Cache poetry
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
container:
image: returntocorp/semgrep
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: semgrep scan --error --config auto
env:
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
4 changes: 3 additions & 1 deletion .safety-policy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ security: # configuration for the `safety check` command
#25853: # Example vulnerability ID
# reason: we do not use the vulnerable function # optional, for internal note purposes to communicate with your team. This reason will be reported in the Safety reports
# expires: '2022-10-21' # datetime string - date this ignore will expire, best practice to use this variable
continue-on-vulnerability-error: False # Suppress non-zero exit codes when vulnerabilities are found. Enable this in pipelines and CI/CD processes if you want to pass builds that have vulnerabilities
70612:
reason: The maintainer and multiple third parties believe that this vulnerability isn't valid because users shouldn't use untrusted templates without sandboxing.
continue-on-vulnerability-error: False # Suppress non-zero exit codes when vulnerabilities are found. Enable this in pipelines and CI/CD processes if you want to pass builds that have vulnerabilities
43 changes: 35 additions & 8 deletions api_client_generation/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,77 @@ code_gen_dir=`pwd`
project_root=$code_gen_dir/..
echo $code_gen_dir

commit_hash=30fcab0fe6eaa26dcc46e7dc5909467332ec8d0d
commit_hash=ab10aa5263cfed89ddae0720cea31eca0c06a003
api_spec_base_url=https://raw.githubusercontent.com/symphonyoss/symphony-api-spec/${commit_hash}
echo $api_spec_base_url

#local_api_spec_base_url=./local

# This function accepts the following parameters (in order):
# - name of the module we want to generate
# - uri of the file to be used for generation
# - uri of the support file needed for the generation
generate_files() {
download_and_generate_files() {
name=$1
file_url=$2
file_name=${file_url##*/}
support_file_url=$3
support_file_name=${support_file_url##*/}

download_files ${file_url} ${file_name} ${support_file_url} ${support_file_name}
generate_files ${name} ${file_name}
cleanup_files ${file_name} ${support_file_name}
}

download_files() {
# download files
file_url=$1
file_name=$2
support_file_url=$3
support_file_name=$4

cd $code_gen_dir
curl $file_url -o $file_name
if [ ! -z "${support_file_name}" ]
then
curl $support_file_url -o $support_file_name
fi
}

generate_files() {

name=$1
file_name=$2

# generate files
java -jar openapi-generator-cli.jar generate -g python -i $file_name --package-name symphony.bdk.gen -o output

# update api files
cd $code_gen_dir/output/symphony/bdk/gen/api/
sed -i ".bak" "s/symphony\.bdk\.gen\.model\./symphony\.bdk\.gen\.${name}_model\./g" *.py
sed -i ".bak" "s/ api\./ ${name}_api\./g" *.py
sed -i "s/symphony\.bdk\.gen\.model\./symphony\.bdk\.gen\.${name}_model\./g" *.py
sed -i "s/ api\./ ${name}_api\./g" *.py
rm __init__.py # we don't care about __init__.py files
cp *.py $project_root/symphony/bdk/gen/${name}_api

# update model files
cd $code_gen_dir/output/symphony/bdk/gen/model/
sed -i ".bak" "s/symphony\.bdk\.gen\.model\./symphony\.bdk\.gen\.${name}_model\./g" *.py
sed -i ".bak" "s/model /${name}_model /g" *.py
sed -i "s/symphony\.bdk\.gen\.model\./symphony\.bdk\.gen\.${name}_model\./g" *.py
sed -i "s/model /${name}_model /g" *.py
rm __init__.py # we don't care about __init__.py files
cp *.py $project_root/symphony/bdk/gen/${name}_model

# update rest.py
cd $code_gen_dir/output/symphony/bdk/gen
cp rest.py $project_root/symphony/bdk/gen/rest.py

cd $code_gen_dir
rm -r output
}

cleanup_files() {
file_name=$1
support_file_name=$2

# remove downloaded files
cd $code_gen_dir
rm -r output
Expand All @@ -57,12 +83,13 @@ generate_files() {
then
rm $support_file_name
fi

}


generate_files agent ${api_spec_base_url}/agent/agent-api-public-deprecated.yaml
generate_files auth ${api_spec_base_url}/authenticator/authenticator-api-public-deprecated.yaml
generate_files login ${api_spec_base_url}/login/login-api-public.yaml
generate_files pod ${api_spec_base_url}/pod/pod-api-public.yaml

generate_files group ${api_spec_base_url}/profile-manager/profile-manager-api.yaml ${api_spec_base_url}/profile-manager/symphony-common-definitions.yaml

#generate_files agent ${local_api_spec_base_url}/agent-api-public-deprecated-formValues-modified.yaml
Loading

0 comments on commit 8ef4d50

Please sign in to comment.