Skip to content

Commit

Permalink
chore: upload test results s3 (#17720)
Browse files Browse the repository at this point in the history
* chore: add job to upload logs to s3 bucket

* chore: update file name

* chore: include webapp in file name

* chore: add test run date

* chore: add timestamp to file name

* chore: commit sha and date as a part of test job

* chore: release tag upload tests to s3

* chore: publish job, upload tests to s3

* chore: env var for file name

* chore: env var for file name
  • Loading branch information
PatrykBuniX authored Jul 8, 2024
1 parent ebb5c21 commit 38b8092
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 14 deletions.
32 changes: 26 additions & 6 deletions .github/workflows/create_docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
create_image:
runs-on: ubuntu-latest

env:
UNIT_TEST_REPORT_FILE: './unit-tests.log'

steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -35,24 +38,41 @@ jobs:
- name: Install JS dependencies
run: yarn --immutable

- name: Set short sha
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Test
run: |
set -o pipefail
yarn test --coverage --coverage-reporters=lcov --detectOpenHandles=false 2>&1 | tee ./unit-tests.log
yarn test --coverage --coverage-reporters=lcov --detectOpenHandles=false 2>&1 | tee ${{ env.UNIT_TEST_REPORT_FILE }}
echo -e "RELEASE TAG = ${{ inputs.tag }}" >> ${{ env.UNIT_TEST_REPORT_FILE }}
echo -e "SHORT COMMIT SHA = ${{ steps.vars.outputs.sha_short }}" >> ${{ env.UNIT_TEST_REPORT_FILE }}
echo -e "TEST RUN DATE = $(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> ${{ env.UNIT_TEST_REPORT_FILE }}
- name: Build
run: yarn build:prod

- name: Set short sha
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Push Docker image
env:
DOCKER_PASSWORD: ${{secrets.WEBTEAM_QUAY_PASSWORD}}
DOCKER_USERNAME: ${{secrets.WEBTEAM_QUAY_USERNAME}}
run: yarn docker "${{inputs.tag}}-${{ steps.vars.outputs.sha_short }}"

- name: Install AWS CLI
run: |
sudo apt-get update
sudo apt-get install -y awscli
- name: Upload unit-tests.log to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: eu-west-1
run: |
TIMESTAMP=$(date -u +'%Y%m%dT%H%M%SZ')
aws s3 cp ${{ env.UNIT_TEST_REPORT_FILE }} s3://wire-webapp/unit-tests-release-${{ inputs.tag }}-${TIMESTAMP}-${{ steps.vars.outputs.sha_short }}.log
- name: Create GitHub release
if: ${{inputs.create_release}}
id: create_release_production
Expand All @@ -62,6 +82,6 @@ jobs:
with:
tag_name: ${{inputs.tag}}
name: ${{inputs.tag}}
files: ./unit-tests.log
files: ${{ env.UNIT_TEST_REPORT_FILE }}
draft: false
prerelease: true
25 changes: 17 additions & 8 deletions .github/workflows/generate_test_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
generate_test_report:
runs-on: ubuntu-latest

env:
UNIT_TEST_REPORT_FILE: './unit-tests.log'

steps:
- name: Checkout
uses: actions/[email protected]
Expand Down Expand Up @@ -45,14 +48,20 @@ jobs:
- name: Test
run: |
set -o pipefail
yarn test --coverage --coverage_reporters=lcov 2>&1 | tee ./unit-tests.log
yarn test --coverage --coverage_reporters=lcov 2>&1 | tee ${{ env.UNIT_TEST_REPORT_FILE }}
echo -e "COMMIT SHA = ${{ inputs.commit }}" >> ${{ env.UNIT_TEST_REPORT_FILE }}
echo -e "TEST RUN DATE = $(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> ${{ env.UNIT_TEST_REPORT_FILE }}
- name: Print environment variables
- name: Install AWS CLI
run: |
echo -e "COMMIT SHA = ${{ inputs.commit }}" >> ./unit-tests.log
sudo apt-get update
sudo apt-get install -y awscli
- name: Save test coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: ./unit-tests.log
- name: Upload unit-tests.log to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: eu-west-1
run: |
TIMESTAMP=$(date -u +'%Y%m%dT%H%M%SZ')
aws s3 cp ${{ env.UNIT_TEST_REPORT_FILE }} s3://wire-webapp/unit-tests-${TIMESTAMP}-${{ inputs.commit }}.log
16 changes: 16 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,28 @@ jobs:
run: |
set -o pipefail
yarn test --detectOpenHandles=false 2>&1 | tee ${{ env.UNIT_TEST_REPORT_FILE }}
echo -e "COMMIT SHA = ${{ github.sha }}" >> ${{env.UNIT_TEST_REPORT_FILE}}
echo -e "TEST RUN DATE = $(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> ${{env.UNIT_TEST_REPORT_FILE}}
- uses: actions/upload-artifact@v4
with:
name: 'unit-tests-report'
path: ${{env.UNIT_TEST_REPORT_FILE}}

- name: Install AWS CLI
run: |
sudo apt-get update
sudo apt-get install -y awscli
- name: Upload unit-tests.log to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: eu-west-1
run: |
TIMESTAMP=$(date -u +'%Y%m%dT%H%M%SZ')
aws s3 cp ${{env.UNIT_TEST_REPORT_FILE}} s3://wire-webapp/unit-tests-${TIMESTAMP}-${{ github.sha }}.log
- name: Build
run: yarn build:prod

Expand Down

0 comments on commit 38b8092

Please sign in to comment.