Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgenmk committed Aug 26, 2024
1 parent 1ac23c1 commit 61df694
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 7 deletions.
20 changes: 13 additions & 7 deletions .github/workflows/on_target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ on:
required: true
type: boolean
description: Build the firmware before running tests
runid:
required: false
type: number
description: The run ID of the build job to download artifacts from

schedule:
- cron: "0 0 * * *"
Expand All @@ -21,7 +17,7 @@ on:

jobs:
build:
if: ${{ github.event.inputs.build == true }}
if: ${{ github.event.inputs.build == ''}}
uses: ./.github/workflows/build.yml
secrets: inherit
with:
Expand All @@ -46,12 +42,22 @@ jobs:
path: thingy91x-oob

- name: Download artifact
if: ${{ github.event.inputs.build == '' }}
uses: actions/download-artifact@v4
with:
name: firmware
path: thingy91x-oob/tests/on_target/artifacts
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Download old artifact
if: ${{ github.event.inputs.build != '' }}
run: |
ls -l
ls -l thingy91x-oob
ls -l thingy91x-oob/tests
ls -l thingy91x-oob/tests/on_target
ls -l thingy91x-oob/tests/on_target/artifacts
python3 thingy91x-oob/tests/on_target/utils/download_artifacts.py \
${{ secrets.GITHUB_TOKEN }}
- name: Set version
shell: bash
Expand Down
40 changes: 40 additions & 0 deletions tests/on_target/utils/download_artifacts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
##########################################################################################
# Copyright (c) 2024 Nordic Semiconductor
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
##########################################################################################

import requests
import argparse
import io
import zipfile

p = argparse.ArgumentParser()
p.add_argument("token", help="GitHub token")
p.add_argument(
"--path",
help="Folder to store artifact",
default="thingy91x-oob/tests/on_target/artifacts",
)

args = p.parse_args()

headers = {
"X-GitHub-Api-Version": "2022-11-28",
"Authorization": f"Bearer {args.token}",
"Accept": "application/vnd.github+json",
}

params = {"per_page": 1, "name": "firmware"}

url = "https://api.github.com/repos/hello-nrfcloud/firmware/actions/artifacts"

r = requests.get(url, headers=headers, params=params)
r.raise_for_status()

download_link = r.json()["artifacts"][0]["archive_download_url"]

r = requests.get(download_link, headers=headers)
r.raise_for_status()

with zipfile.ZipFile(io.BytesIO(r.content)) as z:
z.extractall(args.path)

0 comments on commit 61df694

Please sign in to comment.