Skip to content

Commit

Permalink
Update workflows to obtain a PR at the end of reflect_test_commit.yam…
Browse files Browse the repository at this point in the history
…l which will stimulate docs.yaml and maven.yaml
  • Loading branch information
masesdevelopers committed Jun 27, 2024
1 parent 9931b3e commit 254fe61
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 120 deletions.
59 changes: 25 additions & 34 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,31 @@ jobs:
run_job: ${{ steps.check_files.outputs.run_job }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: check files
id: check_files
run: |
echo "=============== list changed files ==============="
git diff --name-only HEAD^ HEAD
echo "run_job=false" >> $GITHUB_OUTPUT
echo "========== check paths of changed files =========="
git diff --name-only HEAD^ HEAD > files.txt
while IFS= read -r file
do
echo $file
if [[ $file == ".github/workflows/docs.yaml"* ]]; then
echo "Recreate docs was requested"
echo "run_job=true" >> $GITHUB_OUTPUT
break
fi
if [[ $file == "src/documentation/"* ]]; then
echo "This file is under the directory 'src/documentation/'."
echo "run_job=true" >> $GITHUB_OUTPUT
break
fi
if [[ $file == "src/jvm/src/"* ]]; then
echo "This file is under the directory 'src/jvm/src/'."
echo "run_job=true" >> $GITHUB_OUTPUT
break
fi
echo "This files are not in a source directory no action required"
done < files.txt
- id: get_changed_files
uses: masesgroup/retrieve-changed-files@v3
with:
format: 'csv'

- id: check_files
run: |
mapfile -d ',' -t added_modified_files < <(printf '%s,' '${{ steps.get_changed_files.outputs.added_modified }}')
for added_modified_file in "${added_modified_files[@]}"; do
if [[ $added_modified_file == ".github/workflows/docs.yaml"* ]]; then
echo "$added_modified_file is under the directory '.github/workflows'."
echo "run_job=true" >> $GITHUB_OUTPUT
break
fi
if [[ $added_modified_file == "src/documentation/"* ]]; then
echo "$added_modified_file is under the directory 'src/jvm/src/JCOReflector'."
echo "run_job=true" >> $GITHUB_OUTPUT
break
fi
if [[ $added_modified_file == "src/jvm/src/"* ]]; then
echo "$added_modified_file is under the directory 'src/'."
echo "run_job=true" >> $GITHUB_OUTPUT
break
fi
done
# This workflow contains a single job called "build"
build_docs:
Expand Down
57 changes: 24 additions & 33 deletions .github/workflows/maven.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,31 @@ jobs:
run_job: ${{ steps.check_files.outputs.run_job }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2
- id: get_changed_files
uses: masesgroup/retrieve-changed-files@v3
with:
format: 'csv'

- name: check files
id: check_files
run: |
echo "=============== list changed files ==============="
git diff --name-only HEAD^ HEAD
echo "run_job=false" >> $GITHUB_OUTPUT
echo "========== check paths of changed files =========="
git diff --name-only HEAD^ HEAD > files.txt
while IFS= read -r file
do
echo $file
if [[ $file == ".github/workflows/maven.yaml"* ]]; then
echo "A change in workflow was made, a run is requested"
echo "run_job=true" >> $GITHUB_OUTPUT
break
fi
if [[ $file == "src/engine/JCOPOMJCOReflector.template"* ]]; then
echo "A change in template was made, a run is requested"
echo "run_job=true" >> $GITHUB_OUTPUT
break
fi
if [[ $file == "src/jvm/src/"* ]]; then
echo "This file is under the directory 'src/jvm/src/'."
echo "run_job=true" >> $GITHUB_OUTPUT
break
fi
echo "This files are not in a source directory no action required"
done < files.txt
- id: check_files
run: |
mapfile -d ',' -t added_modified_files < <(printf '%s,' '${{ steps.get_changed_files.outputs.added_modified }}')
for added_modified_file in "${added_modified_files[@]}"; do
if [[ $added_modified_file == ".github/workflows/maven.yaml"* ]]; then
echo "$added_modified_file is under the directory '.github/workflows'."
echo "run_job=true" >> $GITHUB_OUTPUT
break
fi
if [[ $added_modified_file == "src/engine/JCOPOMJCOReflector.template"* ]]; then
echo "$added_modified_file is under the directory 'src/jvm/src/JCOReflector'."
echo "run_job=true" >> $GITHUB_OUTPUT
break
fi
if [[ $added_modified_file == "src/jvm/src/"* ]]; then
echo "$added_modified_file is under the directory 'src/'."
echo "run_job=true" >> $GITHUB_OUTPUT
break
fi
done
# This workflow contains a single job called "build"
build_maven:
Expand Down
150 changes: 97 additions & 53 deletions .github/workflows/reflect_test_commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ jobs:
with:
enableCrossOsArchive: true
path: ./src/jvm/
key: JCOReflector_source_${{ github.sha }}
key: JCOReflector_${{ github.run_number }}_${{ github.run_attempt }}_source_${{ github.sha }}

- name: Save JCOReflector bin in cache
uses: actions/cache/save@v4
with:
enableCrossOsArchive: true
path: ./bin/
key: JCOReflector_windows_bin_${{ github.sha }}
key: JCOReflector_${{ github.run_number }}_${{ github.run_attempt }}_windows_bin_${{ github.sha }}

# This workflow contains a single job called "build"
build_linux:
Expand All @@ -163,7 +163,7 @@ jobs:
fail-on-cache-miss: true
enableCrossOsArchive: true
path: ./src/jvm/
key: JCOReflector_source_${{ github.sha }}
key: JCOReflector_${{ github.run_number }}_${{ github.run_attempt }}_source_${{ github.sha }}

# Runs a set of commands using the runners shell
- name: Build JCOReflectorCLI
Expand Down Expand Up @@ -193,7 +193,7 @@ jobs:
with:
enableCrossOsArchive: true
path: ./bin/
key: JCOReflector_linux_bin_${{ github.sha }}
key: JCOReflector_${{ github.run_number }}_${{ github.run_attempt }}_linux_bin_${{ github.sha }}

execute_java_tests_windows:
needs: build_windows
Expand Down Expand Up @@ -226,7 +226,7 @@ jobs:
fail-on-cache-miss: true
enableCrossOsArchive: true
path: ./bin/
key: JCOReflector_windows_bin_${{ github.sha }}
key: JCOReflector_${{ github.run_number }}_${{ github.run_attempt }}_windows_bin_${{ github.sha }}

- name: Set up JDK distribution
uses: actions/setup-java@v4
Expand Down Expand Up @@ -331,7 +331,7 @@ jobs:
fail-on-cache-miss: true
enableCrossOsArchive: true
path: ./bin/
key: JCOReflector_windows_bin_${{ github.sha }}
key: JCOReflector_${{ github.run_number }}_${{ github.run_attempt }}_windows_bin_${{ github.sha }}

- name: Set up JDK distribution
uses: actions/setup-java@v4
Expand Down Expand Up @@ -452,7 +452,7 @@ jobs:
fail-on-cache-miss: true
enableCrossOsArchive: true
path: ./bin/
key: JCOReflector_linux_bin_${{ github.sha }}
key: JCOReflector_${{ github.run_number }}_${{ github.run_attempt }}_linux_bin_${{ github.sha }}

- name: Set up JDK distribution
uses: actions/setup-java@v4
Expand Down Expand Up @@ -544,7 +544,7 @@ jobs:
fail-on-cache-miss: true
enableCrossOsArchive: true
path: ./bin/
key: JCOReflector_linux_bin_${{ github.sha }}
key: JCOReflector_${{ github.run_number }}_${{ github.run_attempt }}_linux_bin_${{ github.sha }}

- name: Set up JDK distribution
uses: actions/setup-java@v4
Expand Down Expand Up @@ -661,7 +661,7 @@ jobs:
fail-on-cache-miss: true
enableCrossOsArchive: true
path: ./bin/
key: JCOReflector_linux_bin_${{ github.sha }}
key: JCOReflector_${{ github.run_number }}_${{ github.run_attempt }}_linux_bin_${{ github.sha }}

- name: Set up JDK distribution
uses: actions/setup-java@v4
Expand Down Expand Up @@ -775,15 +775,15 @@ jobs:
fail-on-cache-miss: true
enableCrossOsArchive: true
path: ./bin/
key: JCOReflector_windows_bin_${{ github.sha }}
key: JCOReflector_${{ github.run_number }}_${{ github.run_attempt }}_windows_bin_${{ github.sha }}

- name: Restore JCOReflector source from cache
uses: actions/cache/restore@v4
with:
fail-on-cache-miss: true
enableCrossOsArchive: true
path: ./src/jvm/
key: JCOReflector_source_${{ github.sha }}
key: JCOReflector_${{ github.run_number }}_${{ github.run_attempt }}_source_${{ github.sha }}

- name: Compress release files
run: |
Expand All @@ -796,49 +796,66 @@ jobs:
echo "GITHUB_COMMIT_MESSAGE=$(echo $GITHUB_SHA | cut -c 1-7)" >> $GITHUB_ENV
shell: bash

- name: Commit statistics changes
if: ${{ github.repository_owner == 'masesgroup'}} #do not push any changes outside main repo
uses: EndBug/add-and-commit@v9
- name: Request a PR to commit changes
if: ${{ github.repository_owner == 'masesgroup' }} # do not push any changes outside main repo or GeneratePR is false
uses: peter-evans/create-pull-request@v6
with:
author_name: github-actions
author_email: 41898282+github-actions[bot]@users.noreply.github.com
add: '.\src\jvm\statistics\*.*'
message: Update statistics after commit ${{ env.GITHUB_COMMIT_MESSAGE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Commit report changes
if: ${{ github.repository_owner == 'masesgroup'}} #do not push any changes outside main repo
uses: EndBug/add-and-commit@v9
with:
author_name: github-actions
author_email: 41898282+github-actions[bot]@users.noreply.github.com
add: '.\src\jvm\README.md'
message: Update README.md after commit ${{ env.GITHUB_COMMIT_MESSAGE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Commit source changes
if: ${{ github.repository_owner == 'masesgroup'}} #do not push any changes outside main repo
uses: EndBug/add-and-commit@v9
with:
author_name: github-actions
author_email: 41898282+github-actions[bot]@users.noreply.github.com
add: '.\src\jvm\src\*.list'
message: Update assembly list after commit ${{ env.GITHUB_COMMIT_MESSAGE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Commit source changes
if: ${{ github.repository_owner == 'masesgroup'}} #do not push any changes outside main repo
uses: EndBug/add-and-commit@v9
with:
author_name: github-actions
author_email: 41898282+github-actions[bot]@users.noreply.github.com
add: '.\src\jvm\src\*.java'
message: Update sources after commit ${{ env.GITHUB_COMMIT_MESSAGE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
branch-suffix: short-commit-hash
add-paths: |
.\src\jvm\statistics\*.*
.\src\jvm\README.md
.\src\jvm\src\*.list
.\src\jvm\src\*.java
commit-message: Update JVM after commit ${{ env.GITHUB_COMMIT_MESSAGE }}
title: Changes by GitHub action
body: Automated changes by GitHub action
reviewers: masesdevelopers
assignees: masesdevelopers
labels: java, documentation, enhancement, .NET Framework, .NET 6, .NET 8

# - name: Commit statistics changes
# if: ${{ github.repository_owner == 'masesgroup'}} #do not push any changes outside main repo
# uses: EndBug/add-and-commit@v9
# with:
# author_name: github-actions
# author_email: 41898282+github-actions[bot]@users.noreply.github.com
# add: '.\src\jvm\statistics\*.*'
# message: Update statistics after commit ${{ env.GITHUB_COMMIT_MESSAGE }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#
# - name: Commit report changes
# if: ${{ github.repository_owner == 'masesgroup'}} #do not push any changes outside main repo
# uses: EndBug/add-and-commit@v9
# with:
# author_name: github-actions
# author_email: 41898282+github-actions[bot]@users.noreply.github.com
# add: '.\src\jvm\README.md'
# message: Update README.md after commit ${{ env.GITHUB_COMMIT_MESSAGE }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#
# - name: Commit source changes
# if: ${{ github.repository_owner == 'masesgroup'}} #do not push any changes outside main repo
# uses: EndBug/add-and-commit@v9
# with:
# author_name: github-actions
# author_email: 41898282+github-actions[bot]@users.noreply.github.com
# add: '.\src\jvm\src\*.list'
# message: Update assembly list after commit ${{ env.GITHUB_COMMIT_MESSAGE }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#
# - name: Commit source changes
# if: ${{ github.repository_owner == 'masesgroup'}} #do not push any changes outside main repo
# uses: EndBug/add-and-commit@v9
# with:
# author_name: github-actions
# author_email: 41898282+github-actions[bot]@users.noreply.github.com
# add: '.\src\jvm\src\*.java'
# message: Update sources after commit ${{ env.GITHUB_COMMIT_MESSAGE }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/upload-artifact@v4
with:
Expand All @@ -859,3 +876,30 @@ jobs:
with:
name: net462
path: .\bin\net462.zip

final_cleanup:
needs: [ execute_finalize ]
if: "always()"
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
fetch-depth: '1'

- name: Clear caches
run: |
gh extension install actions/gh-actions-cache
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list --key JCOReflector_${{ github.run_number }}_${{ github.run_attempt }} )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 254fe61

Please sign in to comment.