Skip to content

Commit

Permalink
[ci] Change Scala-CLI Template Composite Action to Workflow (chipsall…
Browse files Browse the repository at this point in the history
…iance#3457)

* [ci] Scala-CLI Template Action -> Workflow, NFC

Change the existing Scala-CLI composite action to a workflow.  Update
other workflows which now need to work a little differently.  The main
change is that a reusable workflow can only communicate through
uploads/downloads.  Hence, change the job that publishes the Scala-CLI
template to download this from the new, reusable workflow.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>

* [ci] Display Scala-CLI Template in Summary, NFC

Show the resulting Scala-CLI template as a "GITHUB_STEP_SUMMARY" in the
GitHub action for publishing it.  This is likely more useful than making
it available as a download artifact.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>

* [ci] Whitespace cleanup, NFC

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>

---------

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
  • Loading branch information
seldridge authored Aug 4, 2023
1 parent 5fc03cd commit 458953e
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 55 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/build-scala-cli-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and Test Scala-CLI Template

on:
workflow_call:

jobs:
build_template:
name: Build and Test
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
# Need to fetch full history for deriving version
with:
fetch-depth: 0
- name: Install CIRCT
uses: ./.github/workflows/install-circt
with:
github-token: ${{ github.token }}
- name: Cache Scala-CLI
uses: coursier/cache-action@v6
- name: Setup Scala-CLI
uses: VirtusLab/scala-cli-setup@v0.2.1
with:
jvm: adoptium:1.17
apps: sbt
- name: Generate Scala CLI Template
shell: bash
run: |
# Determine the version and insert it into the template
sbt emitVersion
VERSION=$(cat version.txt)
sed "s/@VERSION@/$VERSION/g" .github/workflows/build-scala-cli-template/chisel-template.scala > chisel-template.scala
# If the version does NOT contain SNAPSHOT, remove line including snapshots repo
if ! grep -qi 'snapshot' <<< $VERSION; then
sed -i '1d' chisel-template.scala
fi
# Need to publishLocal to test the template
- name: Publish Local
shell: bash
run: sbt "unipublish / publishLocal"
- name: Test Scala CLI Template
shell: bash
run: scala-cli chisel-template.scala
- name: Upload Template
uses: actions/upload-artifact@v3
with:
name: chisel-template.scala
path: chisel-template.scala
retention-days: 7
34 changes: 0 additions & 34 deletions .github/workflows/build-scala-cli-template/action.yml

This file was deleted.

24 changes: 12 additions & 12 deletions .github/workflows/scala-cli-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ on:
jobs:
generate_scala_cli_template:
name: Generate Scala CLI Template
uses: ./.github/workflows/build-scala-cli-template.yml

publish_template:
name: Generate Scala CLI Template
needs: [generate_scala_cli_template]
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
# Need to fetch full history for deriving version
with:
fetch-depth: 0
- name: Build and Test Scala-CLI Template
uses: ./.github/workflows/build-scala-cli-template
- name: Upload Template
uses: actions/upload-artifact@v3
- name: Download Generated CLI Template
uses: actions/download-artifact@v3
with:
name: chisel-template.scala
path: chisel-template.scala
retention-days: 7
- name: Display Template
run: |
echo "\`\`\`scala" >> $GITHUB_STEP_SUMMARY
cat chisel-template.scala >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
- name: Upload To Release Page
if: github.event_name == 'release'
uses: softprops/action-gh-release@v0.1.15
with:
files: chisel-template.scala

10 changes: 1 addition & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,7 @@ jobs:

scala-cli-template:
name: Test Scala-CLI Template
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# Need to fetch full history for deriving version
with:
fetch-depth: 0
- name: Build and Test Scala-CLI Template
uses: ./.github/workflows/build-scala-cli-template
uses: ./.github/workflows/build-scala-cli-template.yml

# Sentinel job to simplify how we specify which checks need to pass in branch
# protection and in Mergify. This job checks that all jobs were successful.
Expand Down

0 comments on commit 458953e

Please sign in to comment.