Skip to content

Commit

Permalink
Fixed server cache for tbd and oktotest
Browse files Browse the repository at this point in the history
  • Loading branch information
yatinappsmith committed Dec 26, 2023
1 parent 0b977c9 commit e3de779
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions .github/workflows/server-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
# In case this is second attempt try restoring status of the prior attempt from cache
- name: Restore the previous run result
if: inputs.skip-tests != 'true' && steps.changed-files-specific.outputs.any_changed == 'true'
if: inputs.skip-tests != 'true' && (steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch')
id: cache-appsmith
uses: actions/cache@v3
with:
Expand All @@ -97,7 +97,7 @@ jobs:

# Fetch prior run result
- name: Get the previous run result
if: inputs.skip-tests != 'true' && steps.changed-files-specific.outputs.any_changed == 'true'
if: inputs.skip-tests != 'true' && (steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch')
id: run_result
run: |
if [ -f ~/run_result ]; then
Expand All @@ -107,36 +107,35 @@ jobs:
fi
- name: Download the failed test artifact in case of rerun
if: steps.run_result.outputs.run_result == 'failedtest' && steps.changed-files-specific.outputs.any_changed == 'true'
if: steps.run_result.outputs.run_result == 'failedtest' && (steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch')
uses: actions/download-artifact@v3
with:
name: failed-server-tests
path: ~/failed-server-tests

- name: Extract the tests for rerun
id: failed_tests
if: steps.run_result.outputs.run_result == 'failedtest' && steps.changed-files-specific.outputs.any_changed == 'true'
if: steps.run_result.outputs.run_result == 'failedtest' && (steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch')
run: |
failed_tests=$(awk '$0 != "" && !seen[$0]++ {printf("%s%s",sep,$0); sep=","}' ~/failed-server-tests/failed-server-tests.txt)
echo "$failed_tests"
echo "tests=$failed_tests" >> $GITHUB_OUTPUT
# In case of prior failure run the job
- if: steps.run_result.outputs.run_result != 'success' && steps.changed-files-specific.outputs.any_changed == 'true'
- if: steps.run_result.outputs.run_result != 'success' && (steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch')
run: echo "I'm alive!" && exit 0

# Setup Java
- name: Set up JDK 17
if: steps.run_result.outputs.run_result != 'success' && steps.changed-files-specific.outputs.any_changed == 'true'
if: steps.run_result.outputs.run_result != 'success' && (steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch')
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"

# Retrieve maven dependencies from cache. After a successful run, these dependencies are cached again
- name: Cache maven dependencies
if: steps.run_result.outputs.run_result != 'success' && steps.changed-files-specific.outputs.any_changed == 'true'
uses: actions/cache@v3
if: steps.run_result.outputs.run_result != 'success' && (steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch')
env:
cache-name: cache-maven-dependencies
with:
Expand All @@ -150,7 +149,7 @@ jobs:
# Since this is an unreleased build, we get the latest released version number, increment the minor number in it,
# append a `-SNAPSHOT` at it's end to prepare the snapshot version number. This is used as the project's version.
- name: Get the version to tag the Docker image
if: steps.run_result.outputs.run_result != 'success' && steps.changed-files-specific.outputs.any_changed == 'true'
if: steps.run_result.outputs.run_result != 'success' && (steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch')
id: vars
run: |
# Since this is an unreleased build, we set the version to incremented version number with a
Expand All @@ -164,7 +163,7 @@ jobs:
# Build the code
- name: Build
if: steps.run_result.outputs.run_result != 'success' && steps.changed-files-specific.outputs.any_changed == 'true'
if: steps.run_result.outputs.run_result != 'success' && (steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch')
env:
ACTIVE_PROFILE: test
APPSMITH_MONGODB_URI: "mongodb://localhost:27017/mobtools"
Expand All @@ -184,7 +183,7 @@ jobs:
# Test the code
- name: Run only tests
if: (inputs.skip-tests != 'true' || steps.run_result.outputs.run_result == 'failedtest') && steps.changed-files-specific.outputs.any_changed == 'true'
if: (inputs.skip-tests != 'true' || steps.run_result.outputs.run_result == 'failedtest') && (steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch')
env:
ACTIVE_PROFILE: test
APPSMITH_MONGODB_URI: "mongodb://localhost:27017/mobtools"
Expand Down Expand Up @@ -229,7 +228,7 @@ jobs:
if-no-files-found: ignore

- name: Fetch server build from cache
if: steps.changed-files-specific.outputs.any_changed == 'false' && success()
if: steps.changed-files-specific.outputs.any_changed == 'false' && success() && github.event_name != 'push' && github.event_name != 'workflow_dispatch'
env:
cachetoken: ${{ secrets.CACHETOKEN }}
reponame: ${{ github.event.repository.name }}
Expand All @@ -253,7 +252,7 @@ jobs:
# Restore the previous built bundle if present. If not push the newly built into the cache
- name: Restore the previous bundle
if: steps.changed-files-specific.outputs.any_changed == 'true'
if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: actions/cache@v3
with:
path: |
Expand Down

0 comments on commit e3de779

Please sign in to comment.