Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pr test job submission #132

Merged
merged 4 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .github/workflows/build-yocto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
env:
CACHE_DIR: /srv/gh-runners/quic-yocto
KAS_REPO_REF_DIR: /srv/gh-runners/quic-yocto/kas-mirrors
BASE_ARTIFACT_URL: "https://quic-yocto-fileserver-1029608027416.us-central1.run.app/${{ github.run_id }}"

jobs:
kas-lock:
Expand Down Expand Up @@ -107,7 +108,7 @@ jobs:
mv ../kas/build/tmp/deploy/images/${{matrix.machine}} $img_dir

# Instruct our file server to make these files available for download
url="https://quic-yocto-fileserver-1029608027416.us-central1.run.app/${GITHUB_RUN_ID}/${{ matrix.machine }}/"
url="${BASE_ARTIFACT_URL}/${{ matrix.machine }}/"

retries=8
okay=0
Expand Down Expand Up @@ -142,5 +143,11 @@ jobs:
- name: "Print output"
id: print-output
run: |
echo "Downloads URL: https://quic-yocto-fileserver-1029608027416.us-central1.run.app/${GITHUB_RUN_ID}/"
echo "url=\"https://quic-yocto-fileserver-1029608027416.us-central1.run.app/${GITHUB_RUN_ID}/\"" >> $GITHUB_OUTPUT
echo "Downloads URL: ${BASE_ARTIFACT_URL}"
echo "url=\"${BASE_ARTIFACT_URL}\"" >> $GITHUB_OUTPUT
echo "${BASE_ARTIFACT_URL}" > build_url
- name: Upload build URL
uses: actions/upload-artifact@v4
with:
name: build_url
path: build_url
46 changes: 44 additions & 2 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,58 @@
name: Test PR build

run-name: "Tests triggered by PR: ${{ github.event.workflow_run.display_title }}"

on:
workflow_run:
workflows: ["Build on PR"]
types:
- completed

jobs:
retrieve-build-url:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
outputs:
url: ${{ steps.set-build-url.outputs.url }}
steps:
- name: 'Download build URL'
uses: actions/github-script@v6
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "build_url"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
const fs = require('fs');
const path = require('path');
const temp = '${{ runner.temp }}/artifacts';
if (!fs.existsSync(temp)){
fs.mkdirSync(temp);
}
fs.writeFileSync(path.join(temp, 'build_url.zip'), Buffer.from(download.data));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it ZIP-ped?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it comes from the upload-action which zips the content by default: https://github.com/actions/upload-artifact?tab=readme-ov-file#inputs. This code comes from github example


- name: 'Setup build URL'
id: set-build-url
run: |
unzip "${{ runner.temp }}/artifacts/build_url.zip"
BUILD_URL=$(cat build_url)
echo "Build URL: ${BUILD_URL}"
echo "url=${BUILD_URL}" >> $GITHUB_OUTPUT

test:
uses: ./.github/workflows/test.yml
secrets: inherit
if: ${{ github.event.workflow_run.conclusion == 'success' }}
needs: retrieve-build-url
mwasilew marked this conversation as resolved.
Show resolved Hide resolved
with:
url: ${{ github.event.workflow_run.outputs.artifacts_url }}
url: ${{ needs.retrieve-build-url.outputs.url }}

Loading