Skip to content

Commit

Permalink
fixes to use different secrets, show the results in the log (#5367)
Browse files Browse the repository at this point in the history
* fixes to use different secrets, show the results in the log
* propagating aws variabales and disabiling a test if the key is there ut empty
Co-authored-by: Michele Sciabarra <[email protected]>
  • Loading branch information
msciabarra authored Dec 22, 2022
1 parent f717619 commit 21c9a63
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 51 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/0-on-demand.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ env:
SLACK_WEBHOOK: ${{secrets.SLACK_WEBHOOK}}

# (optional) s3 log upload
AWS_BUCKET: ${{ secrets.AWS_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
LOG_BUCKET: ${{ secrets.LOG_BUCKET }}
LOG_ACCESS_KEY_ID: ${{ secrets.LOG_ACCESS_KEY_ID }}
LOG_SECRET_ACCESS_KEY: ${{ secrets.LOG_SECRET_ACCESS_KEY }}
LOG_REGION: ${{ secrets.LOG_REGION }}

# github
GH_BUILD: ${{ github.event_name }}-${{ github.sha }}
Expand All @@ -74,7 +74,7 @@ jobs:
run: "./tools/github/run${{ env.TEST_SUITE }}Tests.sh"
continue-on-error: true
- id: logs
name: Upload Logs
name: Show results and Upload logs
run: ./tools/github/checkAndUploadLogs.sh ${{ env.TEST_SUITE }}
- name: Slack Notification
run: >
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/1-unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ env:
SLACK_WEBHOOK: ${{secrets.SLACK_WEBHOOK}}

# (optional) s3 log upload
AWS_BUCKET: ${{ secrets.AWS_BUCKET }}
LOG_BUCKET: ${{ secrets.LOG_BUCKET }}
LOG_ACCESS_KEY_ID: ${{ secrets.LOG_ACCESS_KEY_ID }}
LOG_SECRET_ACCESS_KEY: ${{ secrets.LOG_SECRET_ACCESS_KEY }}
LOG_REGION: ${{ secrets.LOG_REGION }}

# some tests need also this even if they are empty on pull_requests...
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
Expand All @@ -56,7 +61,7 @@ jobs:
run: "./tools/github/run${{ env.TEST_SUITE }}Tests.sh"
continue-on-error: true
- id: logs
name: Upload Logs
name: Show results and Upload logs
run: ./tools/github/checkAndUploadLogs.sh ${{ env.TEST_SUITE }}
- name: Slack Notification
run: >
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/2-system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ env:
SLACK_WEBHOOK: ${{secrets.SLACK_WEBHOOK}}

# (optional) s3 log upload
AWS_BUCKET: ${{ secrets.AWS_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
LOG_BUCKET: ${{ secrets.LOG_BUCKET }}
LOG_ACCESS_KEY_ID: ${{ secrets.LOG_ACCESS_KEY_ID }}
LOG_SECRET_ACCESS_KEY: ${{ secrets.LOG_SECRET_ACCESS_KEY }}
LOG_REGION: ${{ secrets.LOG_REGION }}

# github
GH_BUILD: ${{ github.event_name }}-${{ github.sha }}
Expand All @@ -56,7 +56,7 @@ jobs:
run: "./tools/github/run${{ env.TEST_SUITE }}Tests.sh"
continue-on-error: true
- id: logs
name: Upload Logs
name: Show results and Upload logs
run: ./tools/github/checkAndUploadLogs.sh ${{ env.TEST_SUITE }}
- name: Slack Notification
run: >
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/3-multi-runtime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ env:
SLACK_WEBHOOK: ${{secrets.SLACK_WEBHOOK}}

# (optional) s3 log upload
AWS_BUCKET: ${{ secrets.AWS_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
LOG_BUCKET: ${{ secrets.LOG_BUCKET }}
LOG_ACCESS_KEY_ID: ${{ secrets.LOG_ACCESS_KEY_ID }}
LOG_SECRET_ACCESS_KEY: ${{ secrets.LOG_SECRET_ACCESS_KEY }}
LOG_REGION: ${{ secrets.LOG_REGION }}

# github
GH_BUILD: ${{ github.event_name }}-${{ github.sha }}
Expand All @@ -56,7 +56,7 @@ jobs:
run: "./tools/github/run${{ env.TEST_SUITE }}Tests.sh"
continue-on-error: true
- id: logs
name: Upload Logs
name: Show results and Upload logs
run: ./tools/github/checkAndUploadLogs.sh ${{ env.TEST_SUITE }}
- name: Slack Notification
run: >
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/4-standalone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ env:
SLACK_WEBHOOK: ${{secrets.SLACK_WEBHOOK}}

# (optional) s3 log upload
AWS_BUCKET: ${{ secrets.AWS_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
LOG_BUCKET: ${{ secrets.LOG_BUCKET }}
LOG_ACCESS_KEY_ID: ${{ secrets.LOG_ACCESS_KEY_ID }}
LOG_SECRET_ACCESS_KEY: ${{ secrets.LOG_SECRET_ACCESS_KEY }}
LOG_REGION: ${{ secrets.LOG_REGION }}

# github
GH_BUILD: ${{ github.event_name }}-${{ github.sha }}
Expand All @@ -56,7 +56,7 @@ jobs:
run: "./tools/github/run${{ env.TEST_SUITE }}Tests.sh"
continue-on-error: true
- id: logs
name: Upload Logs
name: Show results and Upload logs
run: ./tools/github/checkAndUploadLogs.sh ${{ env.TEST_SUITE }}
- name: Slack Notification
run: >
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/5-scheduler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ env:
SLACK_WEBHOOK: ${{secrets.SLACK_WEBHOOK}}

# (optional) s3 log upload
AWS_BUCKET: ${{ secrets.AWS_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
LOG_BUCKET: ${{ secrets.LOG_BUCKET }}
LOG_ACCESS_KEY_ID: ${{ secrets.LOG_ACCESS_KEY_ID }}
LOG_SECRET_ACCESS_KEY: ${{ secrets.LOG_SECRET_ACCESS_KEY }}
LOG_REGION: ${{ secrets.LOG_REGION }}

# github
GH_BUILD: ${{ github.event_name }}-${{ github.sha }}
Expand All @@ -56,7 +56,7 @@ jobs:
run: "./tools/github/run${{ env.TEST_SUITE }}Tests.sh"
continue-on-error: true
- id: logs
name: Upload Logs
name: Show results and Upload logs
run: ./tools/github/checkAndUploadLogs.sh ${{ env.TEST_SUITE }}
- name: Slack Notification
run: >
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/6-performance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ env:
SLACK_WEBHOOK: ${{secrets.SLACK_WEBHOOK}}

# (optional) s3 log upload
AWS_BUCKET: ${{ secrets.AWS_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
LOG_BUCKET: ${{ secrets.LOG_BUCKET }}
LOG_ACCESS_KEY_ID: ${{ secrets.LOG_ACCESS_KEY_ID }}
LOG_SECRET_ACCESS_KEY: ${{ secrets.LOG_SECRET_ACCESS_KEY }}
LOG_REGION: ${{ secrets.LOG_REGION }}

# github
GH_BUILD: ${{ github.event_name }}-${{ github.sha }}
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ The build uploads the logs to an s3 bucket allowing to inspect them with a brows
You need to create the bucket with the following commands:

```
AWS_BUCKET=<name-of-your-bucket>
AWS_REGION=<the-region-you-use>
aws s3 mb s3://$AWS_BUCKET --region $AWS_REGION
aws s3 website s3://$AWS_BUCKET/ --index-document index.html
aws s3api put-bucket-acl --acl public-read --bucket $AWS_BUCKET
LOG_BUCKET=<name-of-your-bucket>
LOG_REGION=<the-region-you-use>
aws s3 mb s3://$LOG_BUCKET --region $LOG_REGION
aws s3 website s3://$LOG_BUCKET/ --index-document index.html
aws s3api put-bucket-acl --acl public-read --bucket $LOG_BUCKET
```

To enable upload to the created bucket you need to set the following secrets:

- `AWS_BUCKET`: name of your bucket in s3 (just the name, without `s3://`); create it before.
- `AWS_ACCESS_KEY_ID`: your aws access key.
- `AWS_SECRET_ACCESS_KEY`: your aws secret key.
- `AWS_REGION`: important: the region where your bucket is.
- `LOG_BUCKET`: name of your bucket in s3 (just the name, without `s3://`); create it before.
- `LOG_ACCESS_KEY_ID`: your aws access key.
- `LOG_SECRET_ACCESS_KEY`: your aws secret key.
- `LOG_REGION`: important: the region where your bucket is.

## Slack notification

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ trait S3Aws extends FlatSpec {

override protected def withFixture(test: NoArgTest) = {
assume(
secretAccessKey != null,
secretAccessKey != null && secretAccessKey != "",
"'AWS_SECRET_ACCESS_KEY' env not configured. Configure following " +
"env variables for test to run. 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'AWS_REGION'")

Expand Down
10 changes: 7 additions & 3 deletions tools/github/checkAndUploadLogs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@
# limitations under the License.
#

# showing test results on the CI log
INDEX="tests/build/reports/tests/testCoverageLean/index.html"
test -f "$INDEX" && lynx -dump file://$PWD/$INDEX | grep .

# check variables
for i in AWS_BUCKET AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_REGION
for i in LOG_BUCKET LOG_ACCESS_KEY_ID LOG_SECRET_ACCESS_KEY LOG_REGION
do
if test -z "${!i}"
then echo "Required Environment Variable Missing: $i" ; exit 1
then echo "Required Environment Variable Missing: $i" ; exit 0
fi
done

Expand All @@ -42,7 +46,7 @@ TAGS=""
[[ "$2" == "Unit" ]] && TAGS="db"

LOG_DIR="$(date +%Y-%m-%d)/${LOG_NAME}-${GH_BUILD}-${GH_BRANCH}"
BUCKET_URL="https://$AWS_BUCKET.s3.$AWS_REGION.amazonaws.com"
BUCKET_URL="https://$LOG_BUCKET.s3.$LOG_REGION.amazonaws.com"

echo "Logs: ${BUCKET_URL}/index.html#${LOG_DIR}/"
echo "Reports: ${BUCKET_URL}/${LOG_DIR}/test-reports/reports/tests/testCoverageLean/index.html"
Expand Down
14 changes: 7 additions & 7 deletions tools/github/s3-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#

# check variables
for i in AWS_BUCKET AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY
for i in LOG_BUCKET LOG_ACCESS_KEY_ID LOG_SECRET_ACCESS_KEY
do
if test -z "${!i}"
then echo "Please set $i" ; exit 1
Expand All @@ -32,7 +32,7 @@ FROM="$1"
TO="$2"

BROWSER="https://raw.githubusercontent.com/qoomon/aws-s3-bucket-browser/master/index.html"
BUCKET_URL="https://$AWS_BUCKET.s3.$AWS_REGION.amazonaws.com/"
BUCKET_URL="https://$LOG_BUCKET.s3.$LOG_REGION.amazonaws.com/"

# install rclone
if ! which rclone
Expand All @@ -41,13 +41,13 @@ fi

RCLONE="rclone --config /dev/null \
--s3-provider AWS \
--s3-region $AWS_REGION \
--s3-region $LOG_REGION \
--s3-acl public-read \
--s3-access-key-id $AWS_ACCESS_KEY_ID \
--s3-secret-access-key $AWS_SECRET_ACCESS_KEY"
--s3-access-key-id $LOG_ACCESS_KEY_ID \
--s3-secret-access-key $LOG_SECRET_ACCESS_KEY"

curl -s "$BROWSER" |\
sed -e 's!bucketUrl: undefined!bucketUrl: "'$BUCKET_URL'"!' |\
$RCLONE rcat ":s3:$AWS_BUCKET/index.html"
$RCLONE rcat ":s3:$LOG_BUCKET/index.html"

$RCLONE copyto "$FROM" ":s3:$AWS_BUCKET/$TO/"
$RCLONE copyto "$FROM" ":s3:$LOG_BUCKET/$TO/"
3 changes: 3 additions & 0 deletions tools/github/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ function retry() {
fi
}

# lynx utility to show test results on the job run
sudo apt-get -y install lynx

# setup docker to listen in port 4243
sudo systemctl stop docker
sudo sed -i -e 's!/usr/bin/dockerd -H fd://!/usr/bin/dockerd -H tcp://0.0.0.0:4243 -H fd://!' /lib/systemd/system/docker.service
Expand Down

0 comments on commit 21c9a63

Please sign in to comment.