Skip to content

Commit

Permalink
fix(workflows): c.out was not cached after the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Wabri committed Aug 5, 2024
1 parent de73351 commit 54e5920
Showing 1 changed file with 77 additions and 20 deletions.
97 changes: 77 additions & 20 deletions .github/workflows/saptune-ut.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,64 @@ env:
CC_PREFIX: github.com/SUSE/saptune/

jobs:
Setup_Git_Env:
runs-on: ubuntu-latest
outputs:
output1: ${{ steps.branch.outputs.GIT_BRANCH }}
output2: ${{ steps.commit_sha.outputs.GIT_COMMIT_SHA }}
steps:
- uses: actions/checkout@v4

- name: Set ENV (push)
run: |
echo "GIT_BRANCH=${{ github.ref }}" >> $GITHUB_ENV
echo "GIT_COMMIT_SHA=${{ github.sha }}" >> $GITHUB_ENV
if: github.event_name == 'push'

- name: Set ENV (pull_request)
run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.head_ref }}
echo "GIT_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV
echo "GIT_COMMIT_SHA=$(git rev-parse origin/${{ github.head_ref }})" >> $GITHUB_ENV
if: github.event_name == 'pull_request'

- id: branch
run: echo "GIT_BRANCH=${GIT_BRANCH}" >> "$GITHUB_OUTPUT"

- id: commit_sha
run: echo "GIT_COMMIT_SHA=${GIT_COMMIT_SHA}" >> "$GITHUB_OUTPUT"

- name: DEBUG
run: echo $GIT_COMMIT_SHA - $GIT_BRANCH

Code_climate_report_before_build:
runs-on: ubuntu-latest
needs: Setup_Git_Env
steps:
- name: DEBUG
env:
GIT_BRANCH: ${{needs.Setup_Git_Env.outputs.branch}}
GIT_COMMIT_SHA: ${{needs.Setup_Git_Env.outputs.commit_sha}}
run: echo $GIT_COMMIT_SHA - $GIT_BRANCH

- name: Download test coverage reporter
run: |
curl -L $CC_TEST_REPORTER_URL > ./cc-test-reporter
chmod +x ./cc-test-reporter
- uses: actions/upload-artifact@v4
with:
name: codeclimate-reporter
path: cc-test-reporter

- name: Run the test reporter before-build
env:
GIT_BRANCH: ${{needs.Setup_Git_Env.outputs.branch}}
GIT_COMMIT_SHA: ${{needs.Setup_Git_Env.outputs.commit_sha}}
run: ./cc-test-reporter before-build

Saptune_unit_test:
needs: Code_climate_report_before_build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -31,37 +88,37 @@ jobs:
- name: Run saptune unit tests
run: docker exec -t saptune-ci /bin/sh -c "cd /app; ./run_saptune_ci_tst.sh;"

- uses: actions/upload-artifact@v4
with:
name: coverprofile
path: c.out

- name: Stop and remove Container Image
run: |
docker stop saptune-ci
docker rm saptune-ci
Code_climate_report:
Code_climate_report_after_build:
needs: Saptune_unit_test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set ENV for codeclimate (push)
run: |
echo "GIT_BRANCH=${{ github.ref }}" >> $GITHUB_ENV
echo "GIT_COMMIT_SHA=${{ github.sha }}" >> $GITHUB_ENV
if: github.event_name == 'push'
- name: DEBUG
env:
GIT_BRANCH: ${{needs.Setup_Git_Env.outputs.branch}}
GIT_COMMIT_SHA: ${{needs.Setup_Git_Env.outputs.commit_sha}}
run: echo $GIT_COMMIT_SHA - $GIT_BRANCH

- name: Set ENV for codeclimate (pull_request)
run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.head_ref }}
echo "GIT_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV
echo "GIT_COMMIT_SHA=$(git rev-parse origin/${{ github.head_ref }})" >> $GITHUB_ENV
if: github.event_name == 'pull_request'
- uses: actions/download-artifact@v4
with:
name: coverprofile

- name: Download test coverage reporter
run: |
curl -L $CC_TEST_REPORTER_URL > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
- uses: actions/download-artifact@v4
with:
name: codeclimate-reporter

- name: Code Climate report coverage
env:
GIT_BRANCH: ${{needs.Setup_Git_Env.outputs.branch}}
GIT_COMMIT_SHA: ${{needs.Setup_Git_Env.outputs.commit_sha}}
run: ./cc-test-reporter after-build --debug --prefix ${{ env.CC_PREFIX }} --exit-code $?
if: ${{ env.CC_TEST_REPORTER_ID }}

0 comments on commit 54e5920

Please sign in to comment.