-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test to ensure that artifacts filtering works
- Loading branch information
Showing
6 changed files
with
267 additions
and
0 deletions.
There are no files selected for viewing
176 changes: 176 additions & 0 deletions
176
src/sbt-test/sbtghactions/non-existent-target/.github/workflows/ci.yml
This file contains 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,176 @@ | ||
# This file was automatically generated by sbt-github-actions using the | ||
# githubWorkflowGenerate task. You should add and commit this file to | ||
# your git repository. It goes without saying that you shouldn't edit | ||
# this file by hand! Instead, if you wish to make changes, you should | ||
# change your sbt build configuration to revise the workflow description | ||
# to meet your needs, then regenerate this file. | ||
|
||
name: Continuous Integration | ||
|
||
on: | ||
pull_request: | ||
branches: ['*'] | ||
push: | ||
branches: ['*'] | ||
|
||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
build: | ||
name: Build and Test | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
scala: [2.13.2] | ||
java: [[email protected]] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout current branch (fast) | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Java and Scala | ||
uses: olafurpg/setup-scala@v5 | ||
with: | ||
java-version: ${{ matrix.java }} | ||
|
||
- name: Cache ivy2 | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.ivy2/cache | ||
key: ${{ runner.os }}-sbt-ivy-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} | ||
|
||
- name: Cache coursier (generic) | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.coursier/cache/v1 | ||
key: ${{ runner.os }}-generic-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} | ||
|
||
- name: Cache coursier (linux) | ||
if: contains(runner.os, 'linux') | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.cache/coursier/v1 | ||
key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} | ||
|
||
- name: Cache coursier (macOS) | ||
if: contains(runner.os, 'macos') | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/Library/Caches/Coursier/v1 | ||
key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} | ||
|
||
- name: Cache coursier (windows) | ||
if: contains(runner.os, 'windows') | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/AppData/Local/Coursier/Cache/v1 | ||
key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} | ||
|
||
- name: Cache sbt | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.sbt | ||
key: ${{ runner.os }}-sbt-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} | ||
|
||
- name: Check that workflows are up to date | ||
run: sbt ++${{ matrix.scala }} githubWorkflowCheck | ||
|
||
- run: sbt ++${{ matrix.scala }} withTarget/compile | ||
|
||
- name: Upload target directory 'target' (${{ matrix.scala }}) | ||
uses: actions/upload-artifact@v1 | ||
with: | ||
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}-target | ||
path: target | ||
|
||
- name: Upload target directory 'withTarget/target' (${{ matrix.scala }}) | ||
uses: actions/upload-artifact@v1 | ||
with: | ||
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}-withTarget_target | ||
path: withTarget/target | ||
|
||
- name: Upload target directory 'project/target' | ||
uses: actions/upload-artifact@v1 | ||
with: | ||
name: target-${{ matrix.os }}-${{ matrix.java }}-project_target | ||
path: project/target | ||
|
||
publish: | ||
name: Publish Artifacts | ||
needs: [build] | ||
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/master') | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
scala: [2.13.2] | ||
java: [[email protected]] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout current branch (fast) | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Java and Scala | ||
uses: olafurpg/setup-scala@v5 | ||
with: | ||
java-version: ${{ matrix.java }} | ||
|
||
- name: Cache ivy2 | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.ivy2/cache | ||
key: ${{ runner.os }}-sbt-ivy-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} | ||
|
||
- name: Cache coursier (generic) | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.coursier/cache/v1 | ||
key: ${{ runner.os }}-generic-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} | ||
|
||
- name: Cache coursier (linux) | ||
if: contains(runner.os, 'linux') | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.cache/coursier/v1 | ||
key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} | ||
|
||
- name: Cache coursier (macOS) | ||
if: contains(runner.os, 'macos') | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/Library/Caches/Coursier/v1 | ||
key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} | ||
|
||
- name: Cache coursier (windows) | ||
if: contains(runner.os, 'windows') | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/AppData/Local/Coursier/Cache/v1 | ||
key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} | ||
|
||
- name: Cache sbt | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.sbt | ||
key: ${{ runner.os }}-sbt-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} | ||
|
||
- name: Download target directory 'target' (2.13.2) | ||
uses: actions/download-artifact@v1 | ||
with: | ||
name: target-${{ matrix.os }}-2.13.2-${{ matrix.java }}-target | ||
path: target | ||
|
||
- name: Download target directory 'withTarget/target' (2.13.2) | ||
uses: actions/download-artifact@v1 | ||
with: | ||
name: target-${{ matrix.os }}-2.13.2-${{ matrix.java }}-withTarget_target | ||
path: withTarget/target | ||
|
||
- name: Download target directory 'project/target' | ||
uses: actions/download-artifact@v1 | ||
with: | ||
name: target-${{ matrix.os }}-${{ matrix.java }}-project_target | ||
path: project/target | ||
|
||
- name: Publish project | ||
run: sbt ++${{ matrix.scala }} +publish |
59 changes: 59 additions & 0 deletions
59
src/sbt-test/sbtghactions/non-existent-target/.github/workflows/clean.yml
This file contains 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,59 @@ | ||
# This file was automatically generated by sbt-github-actions using the | ||
# githubWorkflowGenerate task. You should add and commit this file to | ||
# your git repository. It goes without saying that you shouldn't edit | ||
# this file by hand! Instead, if you wish to make changes, you should | ||
# change your sbt build configuration to revise the workflow description | ||
# to meet your needs, then regenerate this file. | ||
|
||
name: Clean | ||
|
||
on: push | ||
|
||
jobs: | ||
delete-artifacts: | ||
name: Delete Artifacts | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- name: Delete artifacts | ||
run: | | ||
# Customize those three lines with your repository and credentials: | ||
REPO=https://api.github.com/repos/$1 | ||
# A shortcut to call GitHub API. | ||
ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; } | ||
# A temporary file which receives HTTP response headers. | ||
TMPFILE=/tmp/tmp.$$ | ||
# An associative array, key: artifact name, value: number of artifacts of that name. | ||
declare -A ARTCOUNT | ||
# Process all artifacts on this repository, loop on returned "pages". | ||
URL=$REPO/actions/artifacts | ||
while [[ -n "$URL" ]]; do | ||
# Get current page, get response headers in a temporary file. | ||
JSON=$(ghapi --dump-header $TMPFILE "$URL") | ||
# Get URL of next page. Will be empty if we are at the last page. | ||
URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*<//' -e 's/>.*//') | ||
rm -f $TMPFILE | ||
# Number of artifacts on this page: | ||
COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') )) | ||
# Loop on all artifacts on this page. | ||
for ((i=0; $i < $COUNT; i++)); do | ||
# Get name of artifact and count instances of this name. | ||
name=$(jq <<<$JSON -r ".artifacts[$i].name?") | ||
ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1)) | ||
id=$(jq <<<$JSON -r ".artifacts[$i].id?") | ||
size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") )) | ||
printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size | ||
ghapi -X DELETE $REPO/actions/artifacts/$id | ||
done | ||
done |
This file contains 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,25 @@ | ||
organization := "com.codecommit" | ||
version := "0.0.1" | ||
|
||
ThisBuild / crossScalaVersions := Seq("2.13.2") | ||
ThisBuild / scalaVersion := crossScalaVersions.value.head | ||
|
||
// explicitly don't build `withoutTarget` | ||
ThisBuild / githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("withTarget/compile"))) | ||
|
||
def withoutTargetPredicate(step: WorkflowStep): Boolean = step match { | ||
case step: WorkflowStep.Use => step.params("path").startsWith("withoutTarget") | ||
case _ => false | ||
} | ||
|
||
ThisBuild / githubWorkflowGeneratedUploadSteps := | ||
(ThisBuild / githubWorkflowGeneratedUploadSteps).value.filterNot(withoutTargetPredicate) | ||
|
||
ThisBuild / githubWorkflowGeneratedDownloadSteps := | ||
(ThisBuild / githubWorkflowGeneratedDownloadSteps).value.filterNot(withoutTargetPredicate) | ||
|
||
lazy val root = project.in(file(".")).aggregate(withTarget, withoutTarget) | ||
|
||
lazy val withTarget = project.in(file("withTarget")) | ||
|
||
lazy val withoutTarget = project.in(file("withoutTarget")) |
1 change: 1 addition & 0 deletions
1
src/sbt-test/sbtghactions/non-existent-target/project/build.properties
This file contains 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 @@ | ||
sbt.version=1.3.7 |
5 changes: 5 additions & 0 deletions
5
src/sbt-test/sbtghactions/non-existent-target/project/plugins.sbt
This file contains 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,5 @@ | ||
sys.props.get("plugin.version") match { | ||
case Some(x) => addSbtPlugin("com.codecommit" % "sbt-github-actions" % x) | ||
case _ => sys.error("""|The system property 'plugin.version' is not defined. | ||
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin) | ||
} |
This file contains 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 @@ | ||
> githubWorkflowCheck |