-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add sbt-github-actions for basic CI #14
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,47 @@ | ||||||
# 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: [main] | ||||||
push: | ||||||
branches: [main] | ||||||
tags: [v*] | ||||||
|
||||||
env: | ||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need this? this token appears to be unused in this CI job There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its there by default but I might be able to turn it off. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So from https://github.com/sbt/sbt-github-actions#generative-1
So to me the reasoning behind this is sensible considering. I am not entirely 100% sure if the current actions that are created by sbt-github-actions don't require a token, if you are sure of that I can remove it otherwise as a compromise we can leave it as it is and try to remove it in a future PR (for some reason github actions aren't triggering right now). |
||||||
|
||||||
jobs: | ||||||
build: | ||||||
name: Build and Test | ||||||
strategy: | ||||||
matrix: | ||||||
os: [ubuntu-latest] | ||||||
scala: [2.12.18] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Btw. why is it running on 2.12 in the first place? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its a sbt plugin There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also regarding including the patch version (i.e. |
||||||
java: [temurin@11] | ||||||
runs-on: ${{ matrix.os }} | ||||||
steps: | ||||||
- name: Checkout current branch (full) | ||||||
uses: actions/checkout@v3 | ||||||
with: | ||||||
fetch-depth: 0 | ||||||
|
||||||
- name: Setup Java (temurin@11) | ||||||
if: matrix.java == 'temurin@11' | ||||||
uses: actions/setup-java@v3 | ||||||
with: | ||||||
distribution: temurin | ||||||
java-version: 11 | ||||||
cache: sbt | ||||||
|
||||||
- name: Check that workflows are up to date | ||||||
run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck | ||||||
|
||||||
- name: Build project | ||||||
run: sbt '++ ${{ matrix.scala }}' test paradox |
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=${GITHUB_API_URL}/repos/${{ github.repository }} | ||
|
||
# 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,16 @@ pekkoParadoxGithub := Some("https://github.com/apache/incubator-pekko-site") | |
inConfig(Assets)(Seq( | ||
excludeFilter := excludeFilter.value -- ".htaccess" | ||
)) | ||
|
||
ThisBuild / githubWorkflowTargetBranches := Seq("main") | ||
ThisBuild / githubWorkflowTargetTags ++= Seq("v*") | ||
ThisBuild / githubWorkflowPublishTargetBranches := Seq() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intentionally left blank, lets not worry about publishing for now. |
||
|
||
ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("11")) | ||
|
||
ThisBuild / githubWorkflowBuild := Seq( | ||
WorkflowStep.Sbt( | ||
List("test", "paradox"), | ||
name = Some("Build project") | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the lack of a permissions declaration is a problem - it would be great if the sbt plugin supported setting this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does now, I just forgot to set it. By default its full permissions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a suggestion for the permissions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the GitHub Token is not removed, then this is probably what we need