Skip to content
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

[github actions] address test flakiness #360

Merged
merged 8 commits into from Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-dotnet.yml
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v1
- name: Download workflow artifact
uses: dawidd6/action-download-artifact@v2.14.0
uses: dawidd6/action-download-artifact@v2.17.0
fundthmcalculus marked this conversation as resolved.
Show resolved Hide resolved
with:
workflow: "build-libs.yml"
path: ./libs
Expand Down
46 changes: 39 additions & 7 deletions .github/workflows/build-golang.yml
Expand Up @@ -14,39 +14,71 @@ jobs:
strategy:
fail-fast: false
matrix:
os-artifact: [ [ubuntu-latest, linux], [windows-latest, windows], [macos-latest, macos] ]
os-artifact: [ [ubuntu-latest, linux], [windows-latest, windows-gnu], [macos-latest, macos] ]
fundthmcalculus marked this conversation as resolved.
Show resolved Hide resolved
steps:
- uses: actions/checkout@v2
- name: Download workflow artifact
uses: dawidd6/action-download-artifact@v2.14.0
uses: dawidd6/action-download-artifact@v2.17.0
with:
workflow: "build-libs.yml"
path: ./libs/${{ matrix.os-artifact[1] }}
github_token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ matrix.os-artifact[1] }}
- name: Set up Go
- name: Download C header artifact
uses: dawidd6/action-download-artifact@v2.17.0
with:
workflow: "build-libs.yml"
path: ./libs/${{ matrix.os-artifact[1] }}
github_token: ${{ secrets.GITHUB_TOKEN }}
name: C_header
- name: Set up Go (default)
uses: actions/setup-go@v2
with:
go-version: ^1.16
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Set up Dotnet (docs)
run: |
dotnet tool install DefaultDocumentation.Console -g
shell: pwsh
# Set up Okapi-specific Go runtime. Includes setting GOLANG_LD_PATH env var.
- name: Set up Go (Okapi)
run: |
go version
go install golang.org/x/lint/golint@latest
go install github.com/jstemmer/go-junit-report@latest
go get github.com/posener/goreadme/cmd/goreadme
python ../../devops/build_sdks.py --language=golang
shell: pwsh
working-directory: go/okapi
env:
GO111MODULE: on
- name: Build and Test Golang
run: |
go build - name: Set up Go (Okapi)
run: |
go version
go install golang.org/x/lint/golint@latest
go install github.com/jstemmer/go-junit-report@latest
python ../../devops/build_sdks.py
shell: pwsh
working-directory: go/okapi
- name: Build and Test Golang
run: |
go build
golint
go test -v | go-junit-report > test_output.xml
go test -v -exec "env DYLD_LIBRARY_PATH=${{ env.GOLANG_LD_PATH }}" | go-junit-report > test_output.xml
fundthmcalculus marked this conversation as resolved.
Show resolved Hide resolved
shell: pwsh
working-directory: go/okapi
env:
LD_LIBRARY_PATH: "${{ github.workspace }}/go/okapi"
DYLD_FALLBACK_LIBRARY_PATH: "${{ github.workspace }}/go/okapi"
DYLD_LIBRARY_PATH: "${{ github.workspace }}/go/okapi"
LD_LIBRARY_PATH: ${{ env.GOLANG_LD_PATH }}
fundthmcalculus marked this conversation as resolved.
Show resolved Hide resolved
DYLD_FALLBACK_LIBRARY_PATH: ${{ env.GOLANG_LD_PATH }}
DYLD_LIBRARY_PATH: ${{ env.GOLANG_LD_PATH }}
API_GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }}
- name: Upload Unit Test Results - Golang
if: always()
Expand Down
20 changes: 17 additions & 3 deletions .github/workflows/build-java.yml
Expand Up @@ -28,16 +28,30 @@ jobs:
with:
python-version: 3.9
- name: Download workflow artifact
uses: dawidd6/action-download-artifact@v2.14.0
uses: dawidd6/action-download-artifact@v2.17.0
with:
workflow: "build-libs.yml"
path: ./libs/${{ matrix.os-artifact[1] }}
github_token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ matrix.os-artifact[1] }}
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Set up Node (docs)
run: |
npm install groovydoc-to-markdown
shell: pwsh
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Set up Dotnet (docs)
run: |
dotnet tool install DefaultDocumentation.Console -g
shell: pwsh
Comment on lines +37 to +50
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dotnet isn't necessary for java.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I thought we might need to build dotnet docs with all of them since build-dotnet workflow doesn't call this build_sdks script. but that's probably the real problem, we should make it call the script and allow for a real "build all" option

- name: Build with Gradle
run: |
python ../devops/build_sdks.py
gradle build
python ../devops/build_sdks.py --language=java
gradle build
shell: pwsh
working-directory: java
env:
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/build-python.yml
Expand Up @@ -34,18 +34,24 @@ jobs:
cache: 'pip'

- name: Download workflow artifact
uses: dawidd6/action-download-artifact@v2.14.0
uses: dawidd6/action-download-artifact@v2.17.0
with:
workflow: "build-libs.yml"
path: ./libs/${{ matrix.os-artifact[1] }}
github_token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ matrix.os-artifact[1] }}

- uses: actions/setup-dotnet@v1
allibell marked this conversation as resolved.
Show resolved Hide resolved
with:
dotnet-version: '6.0.x'
- name: Set up Dotnet (docs)
run: |
dotnet tool install DefaultDocumentation.Console -g
shell: pwsh
- name: Build, Test, Pack
run: |
python -m pip install --upgrade --upgrade-strategy eager -r requirements.txt
python -m pip install pytest pytest-cov
python ../devops/build_sdks.py
python ../devops/build_sdks.py --language=python
python -m pytest --cache-clear ./tests --junitxml=test_output.xml --cov=.
shell: pwsh
working-directory: python
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/build-ruby.yml
Expand Up @@ -32,18 +32,25 @@ jobs:
cache: 'pip'

- name: Download workflow artifact
uses: dawidd6/action-download-artifact@v2.14.0
uses: dawidd6/action-download-artifact@v2.17.0
with:
workflow: "build-libs.yml"
path: ./libs/${{ matrix.os-artifact[1] }}
github_token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ matrix.os-artifact[1] }}
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Set up Dotnet (docs)
run: |
dotnet tool install DefaultDocumentation.Console -g
shell: pwsh
- name: Build and run tests
run: |
gem install bundler
gem install rspec
bundle install
python ../devops/build_sdks.py
python ../devops/build_sdks.py --language=ruby
bundle exec rake
rake test
exit 0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-dotnet.yml
Expand Up @@ -23,7 +23,7 @@ jobs:
with:
submodules: "true"
- name: Download workflow artifact
uses: dawidd6/action-download-artifact@v2.14.0
uses: dawidd6/action-download-artifact@v2.17.0
with:
workflow: "build-libs.yml"
path: ./libs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-java.yml
Expand Up @@ -31,7 +31,7 @@ jobs:
java-version: '15'
distribution: 'adopt'
- name: Download workflow artifact
uses: dawidd6/action-download-artifact@v2.14.0
uses: dawidd6/action-download-artifact@v2.17.0
with:
workflow: "build-libs.yml"
path: ./libs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-libs.yml
Expand Up @@ -10,7 +10,7 @@ jobs:
name: Upload libs.zip artifact
runs-on: ubuntu-latest
steps:
- uses: dawidd6/action-download-artifact@v2.14.0
- uses: dawidd6/action-download-artifact@v2.17.0
with:
workflow: "build-libs.yml"
path: ./libs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-ruby.yml
Expand Up @@ -30,7 +30,7 @@ jobs:
with:
ruby-version: 2.7
- name: Download workflow artifact
uses: dawidd6/action-download-artifact@v2.14.0
uses: dawidd6/action-download-artifact@v2.17.0
with:
workflow: "build-libs.yml"
path: ./libs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-swift.yml
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: actions/checkout@v1

- name: Download workflow artifact
uses: dawidd6/action-download-artifact@v2.14.0
uses: dawidd6/action-download-artifact@v2.17.0
with:
workflow: "build-libs.yml"
path: ./libs
Expand Down
42 changes: 34 additions & 8 deletions devops/build_sdks.py
Expand Up @@ -41,6 +41,13 @@ def get_os_arch_path(extract_dir, windows_path):
return copy_from



def set_env_var(name, value):
env_file = os.getenv('GITHUB_ENV')
with open(env_file, "a") as file:
file.write(f"{name}={value}")


def copy_okapi_libs(copy_to: str, windows_path='windows'):
okapi_dir = abspath(join(dirname(__file__), '..'))
copy_from = get_os_arch_path(okapi_dir, windows_path)
Expand Down Expand Up @@ -121,8 +128,10 @@ def build_ruby(args) -> None:


def build_golang(args) -> None:
# Update version in setup.cfg
# Copy in Okapi libraries to the $GOLANG_LD_PATH directory
golang_dir = abspath(join(get_language_dir('go'), 'okapi'))
set_env_var("GOLANG_LD_PATH", golang_dir)

# Copy in the binaries
copy_okapi_libs(golang_dir, 'windows-gnu')

Expand All @@ -144,7 +153,12 @@ def get_github_version(github_token: str = None) -> str:
def build_java_docs(args):
# https://github.com/fchastanet/groovydoc-to-markdown
# npm install in the root of sdk
subprocess.Popen(r'node ./node_modules/groovydoc-to-markdown/src/doc2md.js ./java java ./docs/reference/java', cwd=get_sdk_dir() ).wait()
subprocess.Popen(
[
'node', './node_modules/groovydoc-to-markdown/src/doc2md.js',
'./java', 'java', './docs/reference/java'
], cwd=get_sdk_dir()
).wait()


def build_dotnet_docs(args) -> None:
Expand All @@ -153,20 +167,32 @@ def build_dotnet_docs(args) -> None:
assembly_file = './dotnet/Library/Okapi/bin/Debug/net6.0/okapi.dll'
output_doc_folder = './docs/reference/dotnet'
clean_dir(abspath(join(get_sdk_dir(), output_doc_folder)))
subprocess.Popen(f"defaultdocumentation --AssemblyFilePath {assembly_file} --OutputDirectoryPath {output_doc_folder} --FileNameMode Name --GeneratedPages Namespaces",
cwd=get_sdk_dir()).wait()
subprocess.Popen(
[
"defaultdocumentation",
"--AssemblyFilePath", assembly_file,
"--OutputDirectoryPath", output_doc_folder,
"--FileNameMode", "Name",
"--GeneratedPages", "Namespaces",
],
cwd=get_sdk_dir()
).wait()


def build_go_docs(args):
# https://github.com/posener/goreadme
# go get github.com/posener/goreadme/cmd/goreadme
goreadme_args = r'-recursive -functions -methods -types -variabless' # Yes, that's a duplicated s, it's on purpose.
goreadme_args = ['-recursive', '-functions', '-methods', '-types', '-variabless'] # Yes, that's a duplicated s, it's on purpose.
doc_path = abspath(join(get_language_dir('docs'), 'reference', 'go'))

def write_doc_file(input_path: str, output_file: str):
logging.info(f"goreadme(input={input_path}, output={output_file})")
print(f"goreadme(input={input_path}, output={output_file})")
with open(join(doc_path, f'{output_file}.md'), 'w') as output:
subprocess.Popen(rf'goreadme {goreadme_args}', cwd=input_path, stdout=output).wait()
subprocess.Popen(
['goreadme', *goreadme_args],
cwd=input_path, stdout=output
).wait()
# Handle the subdirectories
for sub_folder in glob.glob(join(input_path, '**')):
if isdir(sub_folder):
Expand All @@ -193,14 +219,14 @@ def main():
build_python(args)
if build_all or 'java' in langs_to_build:
build_java(args)
build_java_docs(args)
if build_all or 'ruby' in langs_to_build:
build_ruby(args)
if build_all or 'golang' in langs_to_build:
build_golang(args)
build_go_docs(args)
if build_all or 'docs' in langs_to_build:
build_java_docs(args)
build_dotnet_docs(args)
Comment on lines 228 to 229
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should switch this to dotnet then.

build_go_docs(args)


if __name__ == "__main__":
Expand Down
2 changes: 2 additions & 0 deletions go/okapi/DidComm.go
Expand Up @@ -4,13 +4,15 @@ import (
"github.com/trinsic-id/okapi/go/okapiproto"
)

// DidCommer implements the DIDComm Messaging protocol
allibell marked this conversation as resolved.
Show resolved Hide resolved
type DidCommer interface {
Pack(request *okapiproto.PackRequest) (*okapiproto.PackResponse, error)
Unpack(request *okapiproto.UnpackRequest) (*okapiproto.UnpackResponse, error)
Sign(request *okapiproto.SignRequest) (*okapiproto.SignResponse, error)
Verify(request *okapiproto.VerifyRequest) (*okapiproto.VerifyResponse, error)
}

// DidComm implements the DIDComm Messaging protocol
func DidComm() DidCommer {
return &didComm{}
}
Expand Down
2 changes: 2 additions & 0 deletions go/okapi/Hashing.go
Expand Up @@ -4,13 +4,15 @@ import (
"github.com/trinsic-id/okapi/go/okapiproto"
)

// Hasher implements Blake3 and Sha2 hash functions
type Hasher interface {
Sha256Hash(request *okapiproto.SHA256HashRequest) (*okapiproto.SHA256HashResponse, error)
Blake3Hash(request *okapiproto.Blake3HashRequest) (*okapiproto.Blake3HashResponse, error)
Blake3KeyedHash(request *okapiproto.Blake3KeyedHashRequest) (*okapiproto.Blake3KeyedHashResponse, error)
Blake3DeriveKey(request *okapiproto.Blake3DeriveKeyRequest) (*okapiproto.Blake3DeriveKeyResponse, error)
}

// Hashing implements Blake3 and Sha2 hash functions
func Hashing() Hasher {
return &hasher{}
}
Expand Down
2 changes: 2 additions & 0 deletions go/okapi/LdProofs.go
Expand Up @@ -2,11 +2,13 @@ package okapi

import "github.com/trinsic-id/okapi/go/okapiproto"

// LdProofer implements Linked-Data Proofs
type LdProofer interface {
CreateProof(request *okapiproto.CreateProofRequest) (*okapiproto.CreateProofResponse, error)
VerifyProof(request *okapiproto.VerifyProofRequest) (*okapiproto.VerifyProofResponse, error)
}

// LdProofs implements Linked-Data Proofs
func LdProofs() LdProofer {
return &ldProofs{}
}
Expand Down
2 changes: 2 additions & 0 deletions go/okapi/Oberon.go
Expand Up @@ -2,6 +2,7 @@ package okapi

import "github.com/trinsic-id/okapi/go/okapiproto"

// Oberoner implements Oberon authentication
type Oberoner interface {
CreateKey(request *okapiproto.CreateOberonKeyRequest) (*okapiproto.CreateOberonKeyResponse, error)
CreateToken(request *okapiproto.CreateOberonTokenRequest) (*okapiproto.CreateOberonTokenResponse, error)
Expand All @@ -11,6 +12,7 @@ type Oberoner interface {
VerifyProof(request *okapiproto.VerifyOberonProofRequest) (*okapiproto.VerifyOberonProofResponse, error)
}

// Oberon implements Oberon authentication
func Oberon() Oberoner {
return &oberon{}
}
Expand Down
2 changes: 2 additions & 0 deletions go/okapi/native.go
Expand Up @@ -13,6 +13,7 @@ import (
"unsafe"
)

// NativeError indicates a native protocol error
type NativeError struct {
Message string
InternalError error
Expand All @@ -22,6 +23,7 @@ func (o NativeError) Error() string {
return fmt.Sprintf("Error:%s InternalError:%v", o.Message, o.InternalError)
}

// DidError indicates a DID protocol error
type DidError struct {
Code int
FunctionName string
Expand Down