Skip to content

Commit

Permalink
Github Actions - Link Artifacts in PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdCopter committed Feb 21, 2024
1 parent 7843022 commit 0ba84b8
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 12 deletions.
43 changes: 33 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
targets: [targets-group-1, targets-group-2, targets-group-3, targets-group-rest]
targets: [targets-group-1, targets-group-2, targets-group-3, targets-group-4, targets-group-5, targets-group-6, targets-group-7, targets-group-rest]
outputs:
buildtag: ${{ steps.ids.outputs.buildtag }}
shortsha: ${{ steps.ids.outputs.shortsha }}
Expand Down Expand Up @@ -59,7 +59,9 @@ jobs:
continue-on-error: true

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '2.7'

# EmuFlight version
- name: Get code version
Expand Down Expand Up @@ -132,7 +134,7 @@ jobs:
# Upload the Builds to ZIP file with existing SHA in .hex names
- name: Upload Artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: obj/*.hex
Expand All @@ -150,12 +152,12 @@ jobs:
run: |
echo "Artifact name: ${{ needs.build.outputs.artifact }}"
- name: download artifacts
uses: actions/download-artifact@v2
with:
name: ${{ needs.build.outputs.artifact }}
continue-on-error: false

#- name: download artifacts
# uses: actions/download-artifact@v4
# with:
# name: ${{ needs.build.outputs.artifact }}
# continue-on-error: false
#
# Hide existing/outdated artifacts links
- name: Hide artifacts links from comments.
uses: int128/hide-comment-action@v1
Expand All @@ -165,6 +167,27 @@ jobs:
contains: "Compiled HEX from this Pull-Request. WARNING: No warranty or guarantee of any kind. Test/Fly at your own risk!"
continue-on-error: true

- name: 'Download artifact'
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 == "${{ needs.build.outputs.artifact }}.zip"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/${{ needs.build.outputs.artifact }}.zip`, Buffer.from(download.data));
# Add artifacts links to comments
- name: 'Comment on PR'
uses: actions/github-script@v6
Expand Down Expand Up @@ -206,7 +229,7 @@ jobs:
continue-on-error: true

- name: download artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: ${{ needs.build.outputs.artifact }} #no name parameter will download all artifacts, but create separate subfolders
path: obj
Expand Down
24 changes: 23 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,19 @@ targets-group-2: $(GROUP_2_TARGETS)
## targets-group-3 : build some targets
targets-group-3: $(GROUP_3_TARGETS)

## targets-group-rest: build the rest of the targets (not listed in group 1, 2 or 3)
## targets-group-4 : build some targets
targets-group-4: $(GROUP_4_TARGETS)

## targets-group-5 : build some targets
targets-group-5: $(GROUP_5_TARGETS)

## targets-group-6 : build some targets
targets-group-6: $(GROUP_6_TARGETS)

## targets-group-7 : build some targets
targets-group-7: $(GROUP_7_TARGETS)

## targets-group-rest: build the rest of the targets (not listed in group 1, 2, 3...)
targets-group-rest: $(GROUP_OTHER_TARGETS)

$(VALID_TARGETS):
Expand Down Expand Up @@ -496,10 +508,20 @@ targets:
@echo "Base target: $(BASE_TARGET)"
@echo "targets-group-1: $(GROUP_1_TARGETS)"
@echo "targets-group-2: $(GROUP_2_TARGETS)"
@echo "targets-group-3: $(GROUP_3_TARGETS)"
@echo "targets-group-4: $(GROUP_4_TARGETS)"
@echo "targets-group-5: $(GROUP_5_TARGETS)"
@echo "targets-group-6: $(GROUP_6_TARGETS)"
@echo "targets-group-7: $(GROUP_7_TARGETS)"
@echo "targets-group-rest: $(GROUP_OTHER_TARGETS)"

@echo "targets-group-1: $(words $(GROUP_1_TARGETS)) targets"
@echo "targets-group-2: $(words $(GROUP_2_TARGETS)) targets"
@echo "targets-group-3: $(words $(GROUP_3_TARGETS)) targets"
@echo "targets-group-4: $(words $(GROUP_4_TARGETS)) targets"
@echo "targets-group-5: $(words $(GROUP_5_TARGETS)) targets"
@echo "targets-group-6: $(words $(GROUP_6_TARGETS)) targets"
@echo "targets-group-7: $(words $(GROUP_7_TARGETS)) targets"
@echo "targets-group-rest: $(words $(GROUP_OTHER_TARGETS)) targets"
@echo "total in all groups $(words $(SUPPORTED_TARGETS)) targets"

Expand Down
18 changes: 17 additions & 1 deletion make/targets.mk
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ UNSUPPORTED_TARGETS := \
SUPPORTED_TARGETS := $(filter-out $(UNSUPPORTED_TARGETS), $(VALID_TARGETS))

TARGETS_TOTAL := $(words $(SUPPORTED_TARGETS))
TARGET_GROUPS := 4
TARGET_GROUPS := 8
TARGETS_PER_GROUP := $(shell expr $(TARGETS_TOTAL) / $(TARGET_GROUPS) )

ST := 1
Expand All @@ -99,6 +99,22 @@ ST := $(shell expr $(ET) + 1)
ET := $(shell expr $(ST) + $(TARGETS_PER_GROUP))
GROUP_3_TARGETS := $(wordlist $(ST), $(ET), $(SUPPORTED_TARGETS))

ST := $(shell expr $(ET) + 1)
ET := $(shell expr $(ST) + $(TARGETS_PER_GROUP))
GROUP_4_TARGETS := $(wordlist $(ST), $(ET), $(SUPPORTED_TARGETS))

ST := $(shell expr $(ET) + 1)
ET := $(shell expr $(ST) + $(TARGETS_PER_GROUP))
GROUP_5_TARGETS := $(wordlist $(ST), $(ET), $(SUPPORTED_TARGETS))

ST := $(shell expr $(ET) + 1)
ET := $(shell expr $(ST) + $(TARGETS_PER_GROUP))
GROUP_6_TARGETS := $(wordlist $(ST), $(ET), $(SUPPORTED_TARGETS))

ST := $(shell expr $(ET) + 1)
ET := $(shell expr $(ST) + $(TARGETS_PER_GROUP))
GROUP_7_TARGETS := $(wordlist $(ST), $(ET), $(SUPPORTED_TARGETS))

GROUP_OTHER_TARGETS := $(filter-out $(GROUP_1_TARGETS) $(GROUP_2_TARGETS) $(GROUP_3_TARGETS), $(SUPPORTED_TARGETS))

ifeq ($(filter $(TARGET),$(ALT_TARGETS)), $(TARGET))
Expand Down

0 comments on commit 0ba84b8

Please sign in to comment.