Skip to content

Commit

Permalink
WIP fix sha
Browse files Browse the repository at this point in the history
  • Loading branch information
0yi0 committed Jun 5, 2023
1 parent dd46aec commit 11dde50
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run and Upload
name: Build and Run

on:
workflow_call:
Expand All @@ -9,23 +9,23 @@ on:
version:
type: string
required: true
artifacts-days:
type: number
default: 1
dockerfile:
type: string
required: true
build-args:
type: string
required: false
run-repeat:
type: number
default: 1
resultfile:
type: string
required: true
artifacts-days:
type: number
default: 1
outputs:
artifact:
value: ${{ jobs.run-docker-image.outputs.artifact }}
resultfile:
value: ${{ inputs.resultfile }}
value: ${{ jobs.run-docker-image.outputs.resultfile }}

jobs:
prepare:
Expand All @@ -36,7 +36,7 @@ jobs:
- id: prep
run: |
IMGNAME=wasmmark/${{ inputs.name }}:${{ inputs.version }}
echo imgname=${IMGNAME,,} >> $GITHUB_OUTPUT
echo "imgname=${IMGNAME,,}" >> $GITHUB_OUTPUT
build-docker-image:
needs: [ prepare ]
Expand All @@ -50,11 +50,12 @@ jobs:
- uses: docker/setup-buildx-action@v2
- id: vars
run: |
echo artifact=wasmmark-${{ inputs.name }}-${{ inputs.version }} >> $GITHUB_OUTPUT
echo filepath=/tmp/wasmmark-${{ inputs.name }}-${{ inputs.version }}.tar >> $GITHUB_OUTPUT
FILENAME=wasmmark-${{ inputs.name }}-${{ inputs.version }}
echo "artifact=${FILENAME}" >> $GITHUB_OUTPUT
echo "filepath=/tmp/${FILENAME}.tar" >> $GITHUB_OUTPUT
- uses: docker/build-push-action@v4
with:
build-args: commitish=master
build-args: ${{ inputs.build-args }} # TODO: handle empty case
context: .
file: ${{ inputs.dockerfile }}
tags: ${{ needs.prepare.outputs.imgname }}
Expand All @@ -71,6 +72,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
artifact: ${{ steps.vars.outputs.artifact }}
resultfile: ${{ steps.vars.outputs.filepath }}
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
Expand All @@ -80,8 +82,9 @@ jobs:
path: /tmp
- id: vars
run: |
echo artifact=wasmmark-${{ inputs.resultfile }} >> $GITHUB_OUTPUT
echo filepath=/tmp/${{ inputs.resultfile }} >> $GITHUB_OUTPUT
FILENAME=${{ inputs.name }}-$(date -u '+%y%m%d%H%M')-${{ inputs.version }}
echo "artifact=wasmmark-${FILENAME}" >> $GITHUB_OUTPUT
echo "filepath=/tmp/${FILENAME}.json" >> $GITHUB_OUTPUT
- name: Load and Run Image
run: |
docker load --input /tmp/${{ needs.build-docker-image.outputs.artifact }}.tar
Expand All @@ -91,21 +94,3 @@ jobs:
name: ${{ steps.vars.outputs.artifact }}
path: ${{ steps.vars.outputs.filepath }}
retention-days: ${{ inputs.artifacts-days }}

push-result:
needs: [ run-docker-image ]
name: Push Result of ${{ inputs.name }} (${{ inputs.version }})
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: logs
- uses: actions/download-artifact@v3
with:
name: ${{ needs.run-docker-image.outputs.artifact }}
path: ./result
- uses: EndBug/add-and-commit@v9
with:
add: ./result
default_author: github_actions
message: Result of ${{ inputs.name }} (${{ inputs.version }})
32 changes: 32 additions & 0 deletions .github/workflows/upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Upload

on:
workflow_call:
inputs:
name:
type: string
required: true
version:
type: string
required: true
artifact:
type: string
required: true

jobs:
push-result:
name: Push Result of ${{ inputs.name }} (${{ inputs.version }})
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: logs
- uses: actions/download-artifact@v3
with:
name: ${{ inputs.artifact }}
path: ./result
- uses: EndBug/add-and-commit@v9
with:
add: ./result
default_author: github_actions
message: Result of ${{ inputs.name }}@${{ inputs.version }}
24 changes: 16 additions & 8 deletions .github/workflows/wasmedge-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,37 @@ jobs:
prepare:
runs-on: ubuntu-latest
outputs:
timestamp: ${{ steps.prep.outputs.timestamp }}
version: ${{ steps.prep.outputs.version }}
steps:
- id: prep
run: |
echo timestamp=$(date -u '+%y%m%d%H%M') >> $GITHUB_OUTPUT
echo "version=$(git ls-remote https://github.com/WasmEdge/WasmEdge.git master | cut -f 1)" >> $GITHUB_OUTPUT
wasmedge-latest:
build-wasmedge-latest:
needs: [ prepare ]
uses: ./.github/workflows/run-and-upload.yml
uses: ./.github/workflows/build-and-run.yml
with:
name: WasmEdge
version: ${{ github.sha }}
version: ${{ needs.prepare.outputs.version }}
dockerfile: ./docker/wasmedge-src.Dockerfile
resultfile: wasmedge-${{ needs.prepare.outputs.timestamp }}-${{ github.sha }}.json
build-args: commitish=master

uplaod:
needs: [ prepare, build-wasmedge-latest ]
uses: ./.github/workflows/upload.yml
with:
name: WasmEdge
version: ${{ needs.prepare.outputs.version }}
artifact: ${{ needs.build-wasmedge-latest.artifact }}

summarize:
needs: [ wasmedge-latest ]
needs: [ build-wasmedge-latest ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: ${{ needs.wasmedge-latest.outputs.artifact }}
name: ${{ needs.build-wasmedge-latest.outputs.artifact }}
path: ./result
- run: |
sudo apt install -y jq
Expand Down

0 comments on commit 11dde50

Please sign in to comment.