-
Notifications
You must be signed in to change notification settings - Fork 4
feat(ci): add build of alumet artefact on each PR #34
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,219 @@ | ||
| name: Build Alumet artefacts | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - ".github/**" | ||
| - "deb/**" | ||
| - "docker/**" | ||
| - "rpm/**" | ||
|
|
||
| permissions: | ||
| contents: read | ||
| issues: write | ||
| pull-requests: write | ||
|
|
||
| concurrency: | ||
| group: pr-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
|
|
||
| find-changes: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| run-rpm: ${{ steps.get-modified-files.outputs.rpm }} | ||
| run-deb: ${{ steps.get-modified-files.outputs.deb }} | ||
| run-all: ${{ steps.get-modified-files.outputs.github }} | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
|
|
||
| - id: get-modified-files | ||
| uses: dorny/paths-filter@v4 | ||
| with: | ||
| filters: | | ||
| rpm: | ||
| - 'docker/fedora/**' | ||
| - 'docker/ubi/**' | ||
| - 'rpm/**' | ||
| - '!rpm/**/*.md' | ||
| - '!rpm/**/.gitignore' | ||
|
|
||
| deb: | ||
| - 'deb/**' | ||
| - '!deb/**/*.md' | ||
| - '!deb/**/.gitignore' | ||
|
titouanj marked this conversation as resolved.
|
||
| - 'docker/debian/**' | ||
| - 'docker/ubuntu/**' | ||
|
|
||
| github: | ||
| - '.github/**' | ||
| - '!.github/**/*.md' | ||
|
|
||
| setup-input: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| version: ${{ steps.vars.outputs.VERSION}} | ||
| revision: ${{ steps.vars.outputs.REVISION }} | ||
| steps: | ||
| - name: Retrieve build arguments | ||
| id: vars | ||
| run: | | ||
| TAG=$(curl -L https://api.github.com/repos/alumet-dev/alumet/releases/latest | jq -r '.tag_name') | ||
| echo "VERSION=${TAG#v}" >> "$GITHUB_OUTPUT" | ||
| REF=$(curl -sL "https://api.github.com/repos/alumet-dev/alumet/git/ref/tags/$TAG") | ||
|
|
||
| TYPE=$(echo "$REF" | jq -r '.object.type') | ||
| SHA=$(echo "$REF" | jq -r '.object.sha') | ||
|
|
||
| if [ "$TYPE" = "tag" ]; then | ||
| SHA=$(curl -sL \ | ||
| "https://api.github.com/repos/alumet-dev/alumet/git/tags/$SHA" \ | ||
| | jq -r '.object.sha') | ||
| fi | ||
| echo "REVISION=pr${{ github.event.pull_request.number }}SHA${SHA}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| rpm: | ||
|
titouanj marked this conversation as resolved.
|
||
| uses: ./.github/workflows/build_rpm.yaml | ||
| if: ${{ needs.find-changes.outputs.run-rpm == 'true' || needs.find-changes.outputs.run-all == 'true' }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| arch: [x86_64, aarch64] | ||
| needs: | ||
| - find-changes | ||
| - setup-input | ||
| with: | ||
| arch: ${{ matrix.arch }} | ||
| version: ${{ needs.setup-input.outputs.version }} | ||
| release-version: ${{ needs.setup-input.outputs.revision }} | ||
|
|
||
| deb: | ||
| uses: ./.github/workflows/build_deb.yaml | ||
| if: ${{ needs.find-changes.outputs.run-deb == 'true' || needs.find-changes.outputs.run-all == 'true' }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| arch: [x86_64, aarch64] | ||
| needs: | ||
| - find-changes | ||
| - setup-input | ||
| with: | ||
| arch: ${{ matrix.arch }} | ||
| version: ${{ needs.setup-input.outputs.version }} | ||
| revision: ${{ needs.setup-input.outputs.revision }} | ||
|
|
||
| docker: | ||
| uses: ./.github/workflows/build_docker.yaml | ||
| if: always() && (needs.deb.result == 'success' || needs.rpm.result == 'success') | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| arch: [x86_64, aarch64] | ||
| with: | ||
| arch: ${{ matrix.arch }} | ||
| version: ${{ needs.setup-input.outputs.version }} | ||
| release-version: ${{ needs.setup-input.outputs.revision }} | ||
| needs: | ||
| - find-changes | ||
| - setup-input | ||
| - rpm | ||
| - deb | ||
|
|
||
| comment-output: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| ORDER: 'last' #could be 'first' or 'last' | ||
| SEARCH_STRING: "🔥 Generated artifacts 🔥" | ||
| BODY: "🔥 Generated artifacts 🔥" | ||
| needs: | ||
| - setup-input | ||
| - rpm | ||
| - deb | ||
| - docker | ||
| steps: | ||
| - name: Search for previous comment | ||
| id: find-comment | ||
| uses: actions/github-script@v9 | ||
| with: | ||
| script: | | ||
| const opts = github.rest.issues.listComments.endpoint.merge({ | ||
| issue_number: context.issue.number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| }); | ||
|
|
||
| // Paginate is used to retrieve the comments of every pages. | ||
| // See https://octokit.github.io/rest.js/v21/#pagination. | ||
| var comments = await github.paginate(opts) | ||
|
|
||
| // Reverse comments array if wanted | ||
| // (listComments returns the comments ordered by ascending ID). | ||
| if (process.env.ORDER === 'last') { | ||
| comments.reverse() | ||
| } | ||
|
|
||
| // Iterate over the comments array. | ||
| for (const comment of comments) { | ||
| if (comment.user.login !== 'github-actions[bot]') { | ||
| continue | ||
| } | ||
|
|
||
| if (comment.body.includes(process.env.SEARCH_STRING)) { | ||
| core.setOutput('comment-id', comment.id.toString()) | ||
| break | ||
| } | ||
| } | ||
|
|
||
| - name: Get body | ||
| id: get-body | ||
| uses: actions/github-script@v9 | ||
| with: | ||
| script: | | ||
| const body = process.env.BODY || ""; | ||
|
|
||
| const runUrl = | ||
| `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}` + | ||
| `/actions/runs/${context.runId}`; | ||
|
|
||
| const message = `### ${body} | ||
|
|
||
| --- | ||
|
|
||
| Artefacts can be found there: ${runUrl}`; | ||
| core.info(`Generated comment body:\n${message}`); | ||
| console.log('Generated comment body:\n', message); | ||
| core.notice(`Comment body generated. Length: ${message.length}`); | ||
| core.setOutput('comment-body', message); | ||
|
|
||
| - name: Create a new comment | ||
| if: ${{ steps.find-comment.outputs.comment-id == '' }} | ||
| uses: actions/github-script@v9 | ||
| with: | ||
| script: | | ||
| github.rest.issues.createComment({ | ||
| issue_number: context.issue.number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: `${{ steps.get-body.outputs.comment-body }}` | ||
| }) | ||
|
titouanj marked this conversation as resolved.
|
||
|
|
||
| - name: Update existing comment | ||
| if: ${{ steps.find-comment.outputs.comment-id != '' }} | ||
| uses: actions/github-script@v9 | ||
| with: | ||
| script: | | ||
| const commentId = '${{ steps.find-comment.outputs.comment-id }}'; | ||
| const body = `${{ steps.get-body.outputs.comment-body }}`; | ||
|
|
||
| core.info(`Updating comment ${commentId}`); | ||
| core.info(`Comment body:\n${body}`); | ||
|
|
||
| await github.rest.issues.updateComment({ | ||
| comment_id: Number(commentId), | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body | ||
| }); | ||
|
|
||
| core.info(`Comment ${commentId} updated successfully`); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.