Skip to content

Commit

Permalink
update ci
Browse files Browse the repository at this point in the history
  • Loading branch information
yisraelU committed Jan 25, 2024
1 parent 7a935bf commit 2329f83
Show file tree
Hide file tree
Showing 22 changed files with 154 additions and 88 deletions.
112 changes: 97 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,79 @@ name: Continuous Integration

on:
pull_request:
branches: ['**']
branches: ['**', '!update/**', '!pr/**']
push:
branches: ['**']
tags: [v*]
branches: ['**', '!update/**', '!pr/**']
tags: [v*, v*]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


concurrency:
group: ${{ github.workflow }} @ ${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build and Test
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.12]
scala: [2.13]
java: [temurin@11]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java (temurin@11)
id: setup-java-temurin-11
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v4
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false'
run: sbt +update

- name: Check that workflows are up to date
run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck
run: sbt githubWorkflowCheck

- name: Build project
- name: Check headers and formatting
if: matrix.java == 'temurin@11' && matrix.os == 'ubuntu-latest'
run: sbt '++ ${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck

- name: Test
run: sbt '++ ${{ matrix.scala }}' test

- name: Check binary compatibility
if: matrix.java == 'temurin@11' && matrix.os == 'ubuntu-latest'
run: sbt '++ ${{ matrix.scala }}' mimaReportBinaryIssues

- name: Generate API documentation
if: matrix.java == 'temurin@11' && matrix.os == 'ubuntu-latest'
run: sbt '++ ${{ matrix.scala }}' doc

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: mkdir -p modules/examples/target target modules/test-scenarios/target modules/transformers/target modules/schema/target modules/compliance-tests/target modules/prelude/target modules/http/target project/target

- name: Compress target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: tar cf targets.tar modules/examples/target target modules/test-scenarios/target modules/transformers/target modules/schema/target modules/compliance-tests/target modules/prelude/target modules/http/target project/target

- name: Upload target directories
uses: actions/upload-artifact@v4
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
uses: actions/upload-artifact@v3
with:
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}
path: targets.tar

publish:
Expand All @@ -62,7 +91,6 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.12]
java: [temurin@11]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -72,27 +100,81 @@ jobs:
fetch-depth: 0

- name: Setup Java (temurin@11)
id: setup-java-temurin-11
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v4
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
cache: sbt

- name: Download target directories (2.13.12)
uses: actions/download-artifact@v4
- name: sbt update
if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false'
run: sbt +update

- name: Download target directories (2.13)
uses: actions/download-artifact@v3
with:
name: target-${{ matrix.os }}-2.13.12-${{ matrix.java }}
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13

- name: Inflate target directories (2.13.12)
- name: Inflate target directories (2.13)
run: |
tar xf targets.tar
rm targets.tar
- name: Import signing key
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == ''
env:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
run: echo $PGP_SECRET | base64 -d -i - | gpg --import

- name: Import signing key and strip passphrase
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != ''
env:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
run: |
echo "$PGP_SECRET" | base64 -d -i - > /tmp/signing-key.gpg
echo "$PGP_PASSPHRASE" | gpg --pinentry-mode loopback --passphrase-fd 0 --import /tmp/signing-key.gpg
(echo "$PGP_PASSPHRASE"; echo; echo) | gpg --command-fd 0 --pinentry-mode loopback --change-passphrase $(gpg --list-secret-keys --with-colons 2> /dev/null | grep '^sec:' | cut --delimiter ':' --fields 5 | tail -n 1)
- name: Publish project
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
run: sbt ci-release

dependency-submission:
name: Submit Dependencies
if: github.event_name != 'pull_request'
strategy:
matrix:
os: [ubuntu-latest]
java: [temurin@11]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java (temurin@11)
id: setup-java-temurin-11
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false'
run: sbt +update

- name: Submit Dependencies
uses: scalacenter/sbt-dependency-submission@v2
with:
configs-ignore: test scala-tool scala-doc-tool test-internal
3 changes: 1 addition & 2 deletions .github/workflows/clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Delete artifacts
shell: bash {0}
run: |
# Customize those three lines with your repository and credentials:
REPO=${GITHUB_API_URL}/repos/${{ github.repository }}
Expand All @@ -26,7 +25,7 @@ jobs:
ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; }
# A temporary file which receives HTTP response headers.
TMPFILE=$(mktemp)
TMPFILE=/tmp/tmp.$$
# An associative array, key: artifact name, value: number of artifacts of that name.
declare -A ARTCOUNT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object HttpProtocolCompliance {
).allServerTests()

def clientAndServerTests[Alg[_[_, _, _, _, _]]](
router: Router & ReverseRouter,
router: Router with ReverseRouter,
service: Service[Alg]
): List[ComplianceTest[Task]] =
clientTests(router, service) ++ serverTests(router, service)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package smithy4s.zio.compliancetests

import smithy4s.codecs.*
import smithy4s.codecs._
import smithy4s.dynamic.DynamicSchemaIndex
import smithy4s.dynamic.DynamicSchemaIndex.load
import smithy4s.dynamic.model.Model
import smithy4s.{Blob, Document, Schema, ShapeId}
import zio.test.*
import zio.test._
import zio.{Scope, Task, ZIO}

import java.nio.file.{Path, Paths}
Expand All @@ -16,7 +16,7 @@ abstract class ProtocolComplianceSuite extends ZIOSpecDefault {

def allTests(dsi: DynamicSchemaIndex): List[ComplianceTest[Task]]

override def spec: Spec[TestEnvironment & Scope, Any] = {
override def spec: Spec[TestEnvironment with Scope, Any] = {
suite("Protocol Compliance Tests") {
makeTests()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package smithy4s.zio.compliancetests.internals

import smithy4s.Document.*
import smithy4s.Document._
import smithy4s.codecs.PayloadError
import smithy4s.internals.*
import smithy4s.schema.*
import smithy4s.schema.Primitive.*
import smithy4s.{Schema, *}
import smithy4s.internals._
import smithy4s.schema._
import smithy4s.schema.Primitive._
import smithy4s.{Schema, _}

object CanonicalSmithyDecoder {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package smithy4s.zio.compliancetests.internals

import cats.Eq
import cats.effect.Async
import cats.syntax.all.*
import smithy.test.*
import cats.syntax.all._
import smithy.test._
import smithy4s.http.HttpContractError
import smithy4s.zio.compliancetests.TestConfig.*
import smithy4s.zio.compliancetests.TestConfig._
import smithy4s.zio.compliancetests.internals.eq.EqSchemaVisitor
import smithy4s.zio.compliancetests.{
ComplianceTest,
Expand All @@ -24,7 +24,7 @@ private[compliancetests] class ClientHttpComplianceTestCase[
](reverseRouter: ReverseRouter, serviceInstance: Service[Alg])(implicit
ce: Async[Task]
) {
import reverseRouter.*
import reverseRouter._
private val baseUri = URL.decode("http://localhost/").toOption.get
private[compliancetests] implicit val service: Service[Alg] = serviceInstance

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package smithy4s.zio.compliancetests.internals

import smithy4s.Document.DNull
import smithy4s.schema.*
import smithy4s.schema.Primitive.*
import smithy4s.{Schema, *}
import smithy4s.schema._
import smithy4s.schema.Primitive._
import smithy4s.{Schema, _}
import cats.Id
import java.util.UUID

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
* Copyright 2021-2023 Disney Streaming
*
* Licensed under the Tomorrow Open Source Technology License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://disneystreaming.github.io/TOST-1.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package smithy4s.zio.compliancetests.internals

private[compliancetests] case class IntendedShortCircuit()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package smithy4s.zio.compliancetests.internals

import cats.Eq
import cats.implicits.catsSyntaxSemigroup
import smithy.test.*
import smithy.test._
import smithy4s.codecs.PayloadError
import smithy4s.kinds.*
import smithy4s.kinds._
import smithy4s.zio.compliancetests.ComplianceTest.ComplianceResult
import smithy4s.zio.compliancetests.TestConfig.*
import smithy4s.zio.compliancetests.TestConfig._
import smithy4s.zio.compliancetests.internals.asserts.testResultMonoid
import smithy4s.zio.compliancetests.internals.eq.EqSchemaVisitor
import smithy4s.zio.compliancetests.{
Expand All @@ -27,7 +27,7 @@ private[compliancetests] class ServerHttpComplianceTestCase[
serviceInstance: Service[Alg]
) {

import router.*
import router._

private[compliancetests] val originalService: Service[Alg] = serviceInstance
private val baseUri = URL.decode("http://localhost/").toOption.get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package smithy4s.zio.compliancetests.internals

import cats.Eq
import cats.kernel.Monoid
import cats.syntax.all.*
import cats.syntax.all._
import io.circe.Json
import io.circe.parser.*
import io.circe.parser._
import smithy.test.{HttpRequestTestCase, HttpResponseTestCase}
import smithy4s.zio.compliancetests.ComplianceTest.*
import smithy4s.zio.compliancetests.ComplianceTest._
import zio.http.{Headers, QueryParams}
import zio.test.{TestResult, assertTrue}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package smithy4s.zio.compliancetests.internals.eq

import cats.implicits.toFoldableOps
import smithy4s.*
import smithy4s._
import smithy4s.capability.EncoderK
import cats.syntax.all.*
import smithy4s.schema.{Schema, *}
import smithy4s.zio.compliancetests.internals.eq.Smithy4sEqInstances.*
import cats.syntax.all._
import smithy4s.schema.{Schema, _}
import smithy4s.zio.compliancetests.internals.eq.Smithy4sEqInstances._
import cats.{Eq, Monoid}

import java.util.UUID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package smithy4s.zio.compliancetests.internals.eq
import smithy4s.{Blob, Document, Timestamp}
import cats.Eq
import cats.kernel.instances.StaticMethods
import cats.syntax.all.*
import cats.syntax.all._
trait Smithy4sEqInstances {
implicit def arrayEq[A: Eq]: Eq[Array[A]] = (x: Array[A], y: Array[A]) =>
x.zip(y).forall { case (a, b) => a === b }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import smithy4s.{Hints, Service, ShapeId}
import smithy4s.schema.Schema
import smithy4s.zio.compliancetests.ComplianceTest.ComplianceResult
import zio.ZIO
import zio.http.{Header, Headers, Request, Response}
import zio.http.{Headers, Request, Response}

import java.net.URLDecoder
import java.nio.charset.StandardCharsets
Expand Down
Loading

0 comments on commit 2329f83

Please sign in to comment.