From 492d080ecc81b32f6e238078aa7121ff9d6cf3fa Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Wed, 18 Nov 2020 14:47:56 -0800 Subject: [PATCH] Simplify Github Actions CI --- ...tractBuildDependenciesFromPullRequest.gawk | 66 ----------- .github/scripts/generateGitClones.gawk | 29 ----- .github/scripts/generateVersionOverrides.gawk | 21 ---- .github/workflows/test.yml | 109 ++---------------- 4 files changed, 10 insertions(+), 215 deletions(-) delete mode 100644 .github/scripts/ExtractBuildDependenciesFromPullRequest.gawk delete mode 100644 .github/scripts/generateGitClones.gawk delete mode 100644 .github/scripts/generateVersionOverrides.gawk diff --git a/.github/scripts/ExtractBuildDependenciesFromPullRequest.gawk b/.github/scripts/ExtractBuildDependenciesFromPullRequest.gawk deleted file mode 100644 index a7306705..00000000 --- a/.github/scripts/ExtractBuildDependenciesFromPullRequest.gawk +++ /dev/null @@ -1,66 +0,0 @@ -/^[[:space:]]*"body": / { - # Convert character sequences to character constants - gsub(/\\r/, "") - gsub(/\\n/, "\n") - # Remove trailing punctuation - gsub(/\n*",$/, "") - # Look for the build dependency tag - i=split($0, a, /### Build Dependencies/) - if ( i != 2 ) { - print "no build dependencies" - exit 0 - } - # Throw away everything up to the build dependency tag - $0=a[2] - # Grab the specific build dependencies - i=split($0,a,/\nBuild with: /) - delete a[1] - # Format the individual dependencies - errLines = 0 - depLines = 0 - for (i in a) { - # Remove trailing text - gsub(/\n.*$/, "", a[i]) - n=split(a[i], d, /\s+/) - switch (d[1]) { - case /maven-version/ : - if (n != 3) { - err[errLines++]="unrecognized maven-version stanza: " a[i] "(" n ")" - } - break - - case /git-clone/ : - if (n != 4) { - err[errLines++]="unrecognized git-clone stanza: " a[i] "(" n ")" - } - break - - default: - err[errLines++]="unrecognized build type: " d[1] " - " a[i] - break - - } - # If we don't have any errors, format this dependency line and add it - # to the list of dependency lines. - if (errLines == 0) { - sep="" - line="" - for (n in d) { - line=line sep d[n] - sep=" " - } - dep[depLines++]=line - } - } - # Print either errors (to stderr) or the dependency lines (to stdout) - if (errLines == 0) { - for (n in dep) { - print dep[n] - } - } else { - for (n in err) { - print err[n] > "/dev/stderr" - } - exit 1 - } -} diff --git a/.github/scripts/generateGitClones.gawk b/.github/scripts/generateGitClones.gawk deleted file mode 100644 index 301bf604..00000000 --- a/.github/scripts/generateGitClones.gawk +++ /dev/null @@ -1,29 +0,0 @@ -# Generate commands to: -# - clone, build, and publish dependencies, (on stdout) -# - fetch corresponding shas ( on fd 3) -# Specify "-v verbose=1" on the command line for verbose output (to stderr) -/#/ { - # Strip comments - gsub(/#.*$/,"") -} -/git-clone/ { - project=$2 - repo=$3 - tag=$4 - if (verbose) { - print "writing clone and build commands to stdout." > "/dev/stderr" - } - # Generate commands to do a shallow fetch of all branches, checkout the desired ref/sha, and build and publish the jars. - printf "git clone --no-single-branch --no-checkout --depth 5 %s %s && (cd %s && git checkout %s && sbt +publishLocal)\n",repo,project,project,tag - # If the tag looks like a SHA, assume it is and generate a command to just echo it, - # otherwise, generate a string to fetch the sha from the remote. - # In either case, write the output to fd 3. - if (verbose) { - print "writing sha generation commands to fd 3." > "/dev/stderr" - } - if ( tag ~ /^[[:xdigit:]]+$/ ) { - printf "echo %s\n", tag > "/dev/fd/3" - } else { - printf "git ls-remote --tags --heads %s %s", repo, tag > "/dev/fd/3" - } -} diff --git a/.github/scripts/generateVersionOverrides.gawk b/.github/scripts/generateVersionOverrides.gawk deleted file mode 100644 index 3f8f0e61..00000000 --- a/.github/scripts/generateVersionOverrides.gawk +++ /dev/null @@ -1,21 +0,0 @@ -# Generate suitable definitions for sbt to override default dependency -# specifications in the associated build.sbt, assuming the latter has -# been structured to support this. It should contain something like: -# -# // Provide a managed dependency on X if -DXVersion="" is supplied on the command line. -# val defaultVersions = Seq( -# "chisel3" -> "3.3-SNAPSHOT", -# "treadle" -> "1.2-SNAPSHOT" -# ) -# -# libraryDependencies ++= defaultVersions.map { case (dep, ver) => -# "edu.berkeley.cs" %% dep % sys.props.getOrElse(dep + "Version", ver) } - -/#/ { - # Strip comments - gsub(/#.*$/,"") -} -/maven-version/ { - # Print a series of "-DfooVersion=xxx" to override the default chisel versions in build.sbt - printf "%s-D%sVersion=%s", sep, $2, $3; sep = " " -} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7dcb6010..b9d1cf5e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,108 +3,19 @@ name: Test on: [pull_request] jobs: - build: + test: name: ci runs-on: ubuntu-latest - container: - image: ucbbar/chisel3-tools - options: --user github --entrypoint /bin/bash - env: - CHISEL3_REF: master - FIRRTL_REF: master - FIRRTL_INTERPRETER_REF: master - TREADLE_REF: master - CONTAINER_HOME: /home/github - steps: - - name: id - id: id - run: | - uid=$(id -u) - echo ::set-env name=CONTAINER_HOME::$(if [ "$uid" = "0" ]; then echo "/root"; else echo "/home/github"; fi) - printenv - whoami - git --version - pwd - # Currently, sbt seems to either ignore (or doesn't see) $HOME inside the container, - # and insists on using /home/ (i.e., /home/github). - # Set up symbolic links so /home/gitsub/.{sbt,cache} (inside the container) are links to - # the equivalent directories in $HOME (i.e, /github/home) - - name: link-caches - id: link-caches - run: | - echo "Link $CONTAINER_HOME caches to $HOME" - echo mkdir -p $HOME/.cache $HOME/.ivy2 $HOME/.sbt - mkdir -p $HOME/.cache $HOME/.ivy2 $HOME/.sbt - echo ln -s $HOME/.cache $HOME/.ivy2 $HOME/.sbt $CONTAINER_HOME - ln -s $HOME/.cache $HOME/.ivy2 $HOME/.sbt $CONTAINER_HOME - echo ls -la $HOME . $CONTAINER_HOME - ls -la $HOME . $CONTAINER_HOME - - name: checkout + - name: Checkout uses: actions/checkout@v2 - with: - path: repo - - name: cache-sbt - uses: actions/cache@v1 - env: - cache-name: cache-sbt - with: - path: ~/.sbt - key: build-${{ env.cache-name }}-v1 - restore-keys: | - build-${{ env.cache-name }}- - - name: cache-coursier - uses: actions/cache@v1 - env: - cache-name: cache-coursier - with: - path: ~/.cache - key: build-${{ env.cache-name }}-v1 - restore-keys: | - build-${{ env.cache-name }}- - - name: list - id: list - run: | - echo ls -la . repo ~/.sbt ~/.cache /home/github /home/github/.??* - ls -la . repo ~/.sbt ~/.cache /home/github /home/github/.??* - - name: env - id: env - run: | - echo "cat $GITHUB_EVENT_PATH" - cat $GITHUB_EVENT_PATH - - name: gawk - id: gawk - run: | - gawk -f repo/.github/scripts/ExtractBuildDependenciesFromPullRequest.gawk $GITHUB_EVENT_PATH > deps - ls -l deps - cat deps - gawk -f repo/.github/scripts/generateGitClones.gawk deps > clones.sh 3> shas.sh - cat shas.sh - bash shas.sh > shas - - name: cache-dependencies - id: cache-dependencies - uses: actions/cache@v1 - env: - cache-name: cache-dependencies - with: - path: ~/.ivy2/local - key: build-${{ env.cache-name }}-v1-${{ hashFiles('shas') }} - - name: clone-deps - id: clone-deps - run: | - cat clones.sh - bash clones.sh - if: steps.cache-dependencies.outputs.cache-hit != 'true' - - name: version-deps - id: version-deps - run: | - versionDeps=$(gawk -f repo/.github/scripts/generateVersionOverrides.gawk deps) - echo "versonDeps: $versionDeps" - - name: documentation + - name: Setup Scala + uses: olafurpg/setup-scala@v10 + - name: Cache + uses: coursier/cache-action@v5 + - name: Documentation id: doc - run: cat /dev/null | sbt $versionDeps doc - working-directory: ./repo - - name: test + run: sbt doc + - name: Test id: test - run: cat /dev/null | sbt $versionDeps +test - working-directory: ./repo + run: sbt +test