From 95eff052c6365c1e611dd36bf6ed7399f02aa5ef Mon Sep 17 00:00:00 2001 From: Jean Gomes Date: Wed, 21 Feb 2024 22:32:43 +0000 Subject: [PATCH] Changed yaml files --- .github/workflows/main.yml | 32 +++++ .github/workflows/main.yml~ | 32 +++++ .github/workflows/pylint.yml | 28 ++++ .github/workflows/update_readme.yml | 195 ---------------------------- 4 files changed, 92 insertions(+), 195 deletions(-) create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/main.yml~ create mode 100644 .github/workflows/pylint.yml delete mode 100644 .github/workflows/update_readme.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..dfbf73e --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,32 @@ +name: Update README.md from repository + +on: + push: + paths-ignore: + - '.github/workflows/update-readme.yml' + +jobs: + update-readme: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Checkout TOKEN + run: echo "TOKEN=${{ secrets.TOKENACTION }}" >> $GITHUB_ENV + + - name: Set Branch and Repository Variables + id: set-vars + run: | + echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV + echo "REPOSITORY=${GITHUB_REPOSITORY}" >> $GITHUB_ENV + + - name: Update README.md for project + uses: neutrinomuon/UpdateREADME@v0.0.2 + with: + TOKEN: ${{ env.TOKEN }} + BRANCH: ${{ env.BRANCH }} + REPOSITORY: ${{ env.REPOSITORY }} + FILE: 'README.md' + COMMIT_MESSAGE: 'Update README with new version' diff --git a/.github/workflows/main.yml~ b/.github/workflows/main.yml~ new file mode 100644 index 0000000..efdabde --- /dev/null +++ b/.github/workflows/main.yml~ @@ -0,0 +1,32 @@ +name: Update README.md from repository + +on: + push: + paths-ignore: + - '.github/workflows/update-readme.yml' + +jobs: + update-readme: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Checkout TOKEN + run: echo "TOKEN=${{ secrets.TOKENACTION }}" >> $GITHUB_ENV + + - name: Set Branch and Repository Variables + id: set-vars + run: | + echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV + echo "REPOSITORY=${GITHUB_REPOSITORY}" >> $GITHUB_ENV + + - name: Update README.md for project + uses: neutrinomuon/UpdateREADME@v0.0.2 + with: + TOKEN: ${{ env.TOKEN }} + BRANCH: ${{ env.BRANCH }} + REPOSITORY: ${{ env.REPOSITORY }} + FILE: 'README.md' + COMMIT_MESSAGE: 'Update README with new version' \ No newline at end of file diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml new file mode 100644 index 0000000..d61928f --- /dev/null +++ b/.github/workflows/pylint.yml @@ -0,0 +1,28 @@ +name: Pylint-Test 3.8 to 3.11 + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pylint + pip install tqdm + pip install requests + - name: Analysing the code with pylint in main directory + run: | + pylint setup.py + - name: Analysing the code with pylint in src/python directory + run: | + pylint $(git ls-files 'src/python/*.py') diff --git a/.github/workflows/update_readme.yml b/.github/workflows/update_readme.yml deleted file mode 100644 index acd686a..0000000 --- a/.github/workflows/update_readme.yml +++ /dev/null @@ -1,195 +0,0 @@ -name: Update README and meta.yaml from pyfluxconserving - -on: - push: - branches: - - main - workflow_dispatch: - -jobs: - update-readme: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Install jq - run: sudo apt-get install jq -y - - #- name: Run update-readme script - # run: python scripts/update_readme.py - - - name: Get Commit SHA - run: | - TOKEN=${{ secrets.GITHUB_TOKEN }} - FILE_PATH="README.md" - BRANCH="main" - - # Get the commit SHA of the latest commit for the README.md file - COMMIT_SHA=$(curl -s -X GET \ - -H "Authorization: Bearer $TOKEN" \ - -H "Accept: application/vnd.github+json" \ - "https://api.github.com/repos/neutrinomuon/pyfluxconserving/contents?path=$FILE_PATH&sha=$BRANCH" | jq -r '.[0].sha') - - echo "$COMMIT_SHA" - - - name: Update README with new version - run: | - TOKEN=${{ secrets.GITHUB_TOKEN }} - FILE_PATH="README.md" - BRANCH="main" - COMMIT_MESSAGE="Update README with new version" - - # Get the file SHA from the /contents endpoint - # Needs to use FILES_SHA and not COMMIT_SHA for the update of the file - FILE_SHA=$(curl -s -X GET \ - -H "Authorization: Bearer $TOKEN" \ - -H "Accept: application/vnd.github+json" \ - "https://api.github.com/repos/neutrinomuon/pyfluxconserving/contents/$FILE_PATH?ref=$BRANCH" | jq -r '.sha') - - # Get the commit SHA - #COMMIT_SHA=$(curl -s -X GET \ - # -H "Authorization: Bearer $TOKEN" \ - # -H "Accept: application/vnd.github+json" \ - # -H "X-GitHub-Api-Version: 2022-11-28" \ - # "https://api.github.com/repos/neutrinomuon/pyfluxconserving/contents/$GITHUB_SHA" | jq -r '.sha') - - #VECTOR_COMMIT_SHA=$(curl -s -X GET \ - # -H "Authorization: Bearer $TOKEN" \ - # -H "Accept: application/vnd.github+json" \ - # -H "X-GitHub-Api-Version: 2022-11-28" \ - # "https://api.github.com/repos/neutrinomuon/pyfluxconserving/contents?path=$FILE_PATH" | jq -r '.[0].sha') - - # Get the current file contents - FILE_CONTENT=$(curl -s -X GET \ - -H "Authorization: Bearer $TOKEN" \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - "https://api.github.com/repos/neutrinomuon/pyfluxconserving/contents/$FILE_PATH?ref=$BRANCH" | jq -r '.content') - - # Get the current commit SHA of the file - #CURRENT_COMMIT_SHA=$(curl -s -X GET \ - # -H "Authorization: Bearer $TOKEN" \ - # -H "Accept: application/vnd.github+json" \ - # -H "X-GitHub-Api-Version: 2022-11-28" \ - # "https://api.github.com/repos/neutrinomuon/pyfluxconserving/contents?path=$FILE_PATH" | jq -r '.[0].sha') - - # Print COMMIT_SHAs - echo "FILE_SHA: $FILE_SHA" - #echo "COMMIT_SHA: $COMMIT_SHA" - #echo "CURRENT_COMMIT_SHA: $CURRENT_COMMIT_SHA" - #echo "VECTOR_COMMIT_SHA: $VECTOR_COMMIT_SHA" - - #if [[ -z "$CURRENT_COMMIT_SHA" ]]; then - # echo "Failed to retrieve the current commit SHA for the file: $FILE_PATH" - # exit 1 - #fi - - if [[ -z "$FILE_SHA" ]]; then - echo "Failed to retrieve the current FILE SHA for the file: $FILE_PATH" - exit 1 - fi - - # Decode the file contents - FILE_CONTENT=$(echo "$FILE_CONTENT" | base64 -d) - - # Update the file content with the new version - NEW_VERSION=$(cat version.txt) - UPDATED_CONTENT=$(echo "$FILE_CONTENT" | sed "s/last stable version: .*/last stable version: $NEW_VERSION/") - - # Encode the updated content - # UPDATE_CONTENT_normal=$(echo -n "$UPDATED_CONTENT") - UPDATED_CONTENT=$(echo -n "$UPDATED_CONTENT" | base64) - - # Print debug information - echo "TOKEN: $TOKEN" - # echo "COMMIT_SHA: $COMMIT_SHA" - # echo "FILE_CONTENT: $FILE_CONTENT" - # echo "UPDATED_CONTENT: $UPDATED_CONTENT" - echo "NEW_VERSION: $NEW_VERSION" - - # LAST commit SHA of the file - LAST_COMMIT_SHA=$(curl -s -X GET \ - -H "Authorization: Bearer $TOKEN" \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - "https://api.github.com/repos/neutrinomuon/pyfluxconserving/commits?path=$FILE_PATH" | jq -r '.[0].sha') - - # Prepare the JSON data - JSON_DATA=$(jq -n --arg message "$COMMIT_MESSAGE" --arg content "$UPDATED_CONTENT" --arg branch "$BRANCH" --arg sha $FILE_SHA \ - '{message: $message, content: $content, branch: $branch, sha: $sha}') - - # echo "JSON_DATA: $JSON_DATA" - - # Update the file on GitHub - RESPONSE=$(curl -s -X PUT \ - -H "Authorization: Bearer $TOKEN" \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - -d "$JSON_DATA" \ - "https://api.github.com/repos/neutrinomuon/pyfluxconserving/contents/$FILE_PATH") - - echo "$RESPONSE" - - - name: Update meta.yaml with new version - run: | - TOKEN=${{ secrets.GITHUB_TOKEN }} - FILE_PATH="meta.yaml" - BRANCH="main" - COMMIT_MESSAGE="Update README with new version" - - # Get the file SHA from the /contents endpoint - # Needs to use FILES_SHA and not COMMIT_SHA for the update of the file - FILE_SHA=$(curl -s -X GET \ - -H "Authorization: Bearer $TOKEN" \ - -H "Accept: application/vnd.github+json" \ - "https://api.github.com/repos/neutrinomuon/pyfluxconserving/contents/pyfluxconserving/$FILE_PATH?ref=$BRANCH" | jq -r '.sha') - - # Get the current file contents - FILE_CONTENT=$(curl -s -X GET \ - -H "Authorization: Bearer $TOKEN" \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - "https://api.github.com/repos/neutrinomuon/pyfluxconserving/contents/pyfluxconserving/$FILE_PATH?ref=$BRANCH" | jq -r '.content') - - # Print COMMIT_SHAs - echo "FILE_SHA: $FILE_SHA" - - if [[ -z "$FILE_SHA" ]]; then - echo "Failed to retrieve the current FILE SHA for the file: $FILE_PATH" - exit 1 - fi - - # Decode the file contents - FILE_CONTENT=$(echo "$FILE_CONTENT" | base64 -d) - - # Update the file content with the new version - NEW_VERSION=$(cat version.txt) - #UPDATED_CONTENT=$(echo "$FILE_CONTENT" | sed "s/last stable version: .*/last stable version: $NEW_VERSION/") - #UPDATED_CONTENT=$(echo "$FILE_CONTENT" | sed "s/{% set version = \".*\" %}/{% set version = \"$NEW_VERSION\" %}/") - UPDATED_CONTENT=$(echo "$FILE_CONTENT" | sed "s/{% set version = \".*\" %}/{% set version = \"$NEW_VERSION\" %}/") - - # Encode the updated content - # UPDATE_CONTENT_normal=$(echo -n "$UPDATED_CONTENT") - UPDATED_CONTENT=$(echo -n "$UPDATED_CONTENT" | base64) - - # Print debug information - echo "TOKEN: $TOKEN" - echo "NEW_VERSION: $NEW_VERSION" - - # Prepare the JSON data - JSON_DATA=$(jq -n --arg message "$COMMIT_MESSAGE" --arg content "$UPDATED_CONTENT" --arg branch "$BRANCH" --arg sha $FILE_SHA \ - '{message: $message, content: $content, branch: $branch, sha: $sha}') - - # echo "JSON_DATA: $JSON_DATA" - - # Update the file on GitHub - RESPONSE=$(curl -s -X PUT \ - -H "Authorization: Bearer $TOKEN" \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - -d "$JSON_DATA" \ - "https://api.github.com/repos/neutrinomuon/pyfluxconserving/contents/pyfluxconserving/$FILE_PATH") - - echo "$RESPONSE"