Skip to content

Commit 48d0f98

Browse files
authored
[github actions] address test flakiness (#360)
* [github actions] upgrade action-download-artifact * [github actions] download Go C_header file * [golang] add comment strings to appease aggressive linter * fix LD path getting/setting * don't build docs by default * re-introduce build docs by default * cleanup: rm whitespace change
1 parent faaec92 commit 48d0f98

16 files changed

+124
-29
lines changed

.github/workflows/build-dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Checkout
2121
uses: actions/checkout@v1
2222
- name: Download workflow artifact
23-
uses: dawidd6/action-download-artifact@v2.14.0
23+
uses: dawidd6/action-download-artifact@v2.17.0
2424
with:
2525
workflow: "build-libs.yml"
2626
path: ./libs

.github/workflows/build-golang.yml

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,71 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
os-artifact: [ [ubuntu-latest, linux], [windows-latest, windows], [macos-latest, macos] ]
17+
os-artifact: [ [ubuntu-latest, linux], [windows-latest, windows-gnu], [macos-latest, macos] ]
1818
steps:
1919
- uses: actions/checkout@v2
2020
- name: Download workflow artifact
21-
uses: dawidd6/action-download-artifact@v2.14.0
21+
uses: dawidd6/action-download-artifact@v2.17.0
2222
with:
2323
workflow: "build-libs.yml"
2424
path: ./libs/${{ matrix.os-artifact[1] }}
2525
github_token: ${{ secrets.GITHUB_TOKEN }}
2626
name: ${{ matrix.os-artifact[1] }}
27-
- name: Set up Go
27+
- name: Download C header artifact
28+
uses: dawidd6/[email protected]
29+
with:
30+
workflow: "build-libs.yml"
31+
path: ./libs/${{ matrix.os-artifact[1] }}
32+
github_token: ${{ secrets.GITHUB_TOKEN }}
33+
name: C_header
34+
- name: Set up Go (default)
2835
uses: actions/setup-go@v2
2936
with:
3037
go-version: ^1.16
3138
- name: Set up Python
3239
uses: actions/setup-python@v2
3340
with:
3441
python-version: 3.9
42+
- uses: actions/setup-dotnet@v1
43+
with:
44+
dotnet-version: '6.0.x'
45+
- name: Set up Dotnet (docs)
46+
run: |
47+
dotnet tool install DefaultDocumentation.Console -g
48+
shell: pwsh
49+
# Set up Okapi-specific Go runtime. Includes setting GOLANG_LD_PATH env var.
50+
- name: Set up Go (Okapi)
51+
run: |
52+
go version
53+
go install golang.org/x/lint/golint@latest
54+
go install github.com/jstemmer/go-junit-report@latest
55+
go get github.com/posener/goreadme/cmd/goreadme
56+
python ../../devops/build_sdks.py --language=golang
57+
shell: pwsh
58+
working-directory: go/okapi
59+
env:
60+
GO111MODULE: on
3561
- name: Build and Test Golang
62+
run: |
63+
go build - name: Set up Go (Okapi)
3664
run: |
3765
go version
3866
go install golang.org/x/lint/golint@latest
3967
go install github.com/jstemmer/go-junit-report@latest
4068
python ../../devops/build_sdks.py
69+
shell: pwsh
70+
working-directory: go/okapi
71+
- name: Build and Test Golang
72+
run: |
4173
go build
4274
golint
43-
go test -v | go-junit-report > test_output.xml
75+
go test -v -exec "env DYLD_LIBRARY_PATH=${{ env.GOLANG_LD_PATH }}" | go-junit-report > test_output.xml
4476
shell: pwsh
4577
working-directory: go/okapi
4678
env:
47-
LD_LIBRARY_PATH: "${{ github.workspace }}/go/okapi"
48-
DYLD_FALLBACK_LIBRARY_PATH: "${{ github.workspace }}/go/okapi"
49-
DYLD_LIBRARY_PATH: "${{ github.workspace }}/go/okapi"
79+
LD_LIBRARY_PATH: ${{ env.GOLANG_LD_PATH }}
80+
DYLD_FALLBACK_LIBRARY_PATH: ${{ env.GOLANG_LD_PATH }}
81+
DYLD_LIBRARY_PATH: ${{ env.GOLANG_LD_PATH }}
5082
API_GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }}
5183
- name: Upload Unit Test Results - Golang
5284
if: always()

.github/workflows/build-java.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,30 @@ jobs:
2828
with:
2929
python-version: 3.9
3030
- name: Download workflow artifact
31-
uses: dawidd6/action-download-artifact@v2.14.0
31+
uses: dawidd6/action-download-artifact@v2.17.0
3232
with:
3333
workflow: "build-libs.yml"
3434
path: ./libs/${{ matrix.os-artifact[1] }}
3535
github_token: ${{ secrets.GITHUB_TOKEN }}
3636
name: ${{ matrix.os-artifact[1] }}
37+
- uses: actions/setup-node@v2
38+
with:
39+
node-version: '14'
40+
- name: Set up Node (docs)
41+
run: |
42+
npm install groovydoc-to-markdown
43+
shell: pwsh
44+
- uses: actions/setup-dotnet@v1
45+
with:
46+
dotnet-version: '6.0.x'
47+
- name: Set up Dotnet (docs)
48+
run: |
49+
dotnet tool install DefaultDocumentation.Console -g
50+
shell: pwsh
3751
- name: Build with Gradle
3852
run: |
39-
python ../devops/build_sdks.py
40-
gradle build
53+
python ../devops/build_sdks.py --language=java
54+
gradle build
4155
shell: pwsh
4256
working-directory: java
4357
env:

.github/workflows/build-python.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,24 @@ jobs:
3434
cache: 'pip'
3535

3636
- name: Download workflow artifact
37-
uses: dawidd6/action-download-artifact@v2.14.0
37+
uses: dawidd6/action-download-artifact@v2.17.0
3838
with:
3939
workflow: "build-libs.yml"
4040
path: ./libs/${{ matrix.os-artifact[1] }}
4141
github_token: ${{ secrets.GITHUB_TOKEN }}
4242
name: ${{ matrix.os-artifact[1] }}
43-
43+
- uses: actions/setup-dotnet@v1
44+
with:
45+
dotnet-version: '6.0.x'
46+
- name: Set up Dotnet (docs)
47+
run: |
48+
dotnet tool install DefaultDocumentation.Console -g
49+
shell: pwsh
4450
- name: Build, Test, Pack
4551
run: |
4652
python -m pip install --upgrade --upgrade-strategy eager -r requirements.txt
4753
python -m pip install pytest pytest-cov
48-
python ../devops/build_sdks.py
54+
python ../devops/build_sdks.py --language=python
4955
python -m pytest --cache-clear ./tests --junitxml=test_output.xml --cov=.
5056
shell: pwsh
5157
working-directory: python

.github/workflows/build-ruby.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,25 @@ jobs:
3232
cache: 'pip'
3333

3434
- name: Download workflow artifact
35-
uses: dawidd6/action-download-artifact@v2.14.0
35+
uses: dawidd6/action-download-artifact@v2.17.0
3636
with:
3737
workflow: "build-libs.yml"
3838
path: ./libs/${{ matrix.os-artifact[1] }}
3939
github_token: ${{ secrets.GITHUB_TOKEN }}
4040
name: ${{ matrix.os-artifact[1] }}
41+
- uses: actions/setup-dotnet@v1
42+
with:
43+
dotnet-version: '6.0.x'
44+
- name: Set up Dotnet (docs)
45+
run: |
46+
dotnet tool install DefaultDocumentation.Console -g
47+
shell: pwsh
4148
- name: Build and run tests
4249
run: |
4350
gem install bundler
4451
gem install rspec
4552
bundle install
46-
python ../devops/build_sdks.py
53+
python ../devops/build_sdks.py --language=ruby
4754
bundle exec rake
4855
rake test
4956
exit 0

.github/workflows/release-dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
with:
2424
submodules: "true"
2525
- name: Download workflow artifact
26-
uses: dawidd6/action-download-artifact@v2.14.0
26+
uses: dawidd6/action-download-artifact@v2.17.0
2727
with:
2828
workflow: "build-libs.yml"
2929
path: ./libs

.github/workflows/release-java.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
java-version: '15'
3232
distribution: 'adopt'
3333
- name: Download workflow artifact
34-
uses: dawidd6/action-download-artifact@v2.14.0
34+
uses: dawidd6/action-download-artifact@v2.17.0
3535
with:
3636
workflow: "build-libs.yml"
3737
path: ./libs

.github/workflows/release-libs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
name: Upload libs.zip artifact
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: dawidd6/action-download-artifact@v2.14.0
13+
- uses: dawidd6/action-download-artifact@v2.17.0
1414
with:
1515
workflow: "build-libs.yml"
1616
path: ./libs

.github/workflows/release-ruby.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
with:
3131
ruby-version: 2.7
3232
- name: Download workflow artifact
33-
uses: dawidd6/action-download-artifact@v2.14.0
33+
uses: dawidd6/action-download-artifact@v2.17.0
3434
with:
3535
workflow: "build-libs.yml"
3636
path: ./libs

.github/workflows/release-swift.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
uses: actions/checkout@v1
2323

2424
- name: Download workflow artifact
25-
uses: dawidd6/action-download-artifact@v2.14.0
25+
uses: dawidd6/action-download-artifact@v2.17.0
2626
with:
2727
workflow: "build-libs.yml"
2828
path: ./libs

devops/build_sdks.py

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ def get_os_arch_path(extract_dir, windows_path):
4141
return copy_from
4242

4343

44+
45+
def set_env_var(name, value):
46+
env_file = os.getenv('GITHUB_ENV')
47+
with open(env_file, "a") as file:
48+
file.write(f"{name}={value}")
49+
50+
4451
def copy_okapi_libs(copy_to: str, windows_path='windows'):
4552
okapi_dir = abspath(join(dirname(__file__), '..'))
4653
copy_from = get_os_arch_path(okapi_dir, windows_path)
@@ -121,8 +128,10 @@ def build_ruby(args) -> None:
121128

122129

123130
def build_golang(args) -> None:
124-
# Update version in setup.cfg
131+
# Copy in Okapi libraries to the $GOLANG_LD_PATH directory
125132
golang_dir = abspath(join(get_language_dir('go'), 'okapi'))
133+
set_env_var("GOLANG_LD_PATH", golang_dir)
134+
126135
# Copy in the binaries
127136
copy_okapi_libs(golang_dir, 'windows-gnu')
128137

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

149163

150164
def build_dotnet_docs(args) -> None:
@@ -153,20 +167,32 @@ def build_dotnet_docs(args) -> None:
153167
assembly_file = './dotnet/Library/Okapi/bin/Debug/net6.0/okapi.dll'
154168
output_doc_folder = './docs/reference/dotnet'
155169
clean_dir(abspath(join(get_sdk_dir(), output_doc_folder)))
156-
subprocess.Popen(f"defaultdocumentation --AssemblyFilePath {assembly_file} --OutputDirectoryPath {output_doc_folder} --FileNameMode Name --GeneratedPages Namespaces",
157-
cwd=get_sdk_dir()).wait()
170+
subprocess.Popen(
171+
[
172+
"defaultdocumentation",
173+
"--AssemblyFilePath", assembly_file,
174+
"--OutputDirectoryPath", output_doc_folder,
175+
"--FileNameMode", "Name",
176+
"--GeneratedPages", "Namespaces",
177+
],
178+
cwd=get_sdk_dir()
179+
).wait()
158180

159181

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

166188
def write_doc_file(input_path: str, output_file: str):
167189
logging.info(f"goreadme(input={input_path}, output={output_file})")
190+
print(f"goreadme(input={input_path}, output={output_file})")
168191
with open(join(doc_path, f'{output_file}.md'), 'w') as output:
169-
subprocess.Popen(rf'goreadme {goreadme_args}', cwd=input_path, stdout=output).wait()
192+
subprocess.Popen(
193+
['goreadme', *goreadme_args],
194+
cwd=input_path, stdout=output
195+
).wait()
170196
# Handle the subdirectories
171197
for sub_folder in glob.glob(join(input_path, '**')):
172198
if isdir(sub_folder):
@@ -193,14 +219,14 @@ def main():
193219
build_python(args)
194220
if build_all or 'java' in langs_to_build:
195221
build_java(args)
222+
build_java_docs(args)
196223
if build_all or 'ruby' in langs_to_build:
197224
build_ruby(args)
198225
if build_all or 'golang' in langs_to_build:
199226
build_golang(args)
227+
build_go_docs(args)
200228
if build_all or 'docs' in langs_to_build:
201-
build_java_docs(args)
202229
build_dotnet_docs(args)
203-
build_go_docs(args)
204230

205231

206232
if __name__ == "__main__":

go/okapi/DidComm.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import (
44
"github.com/trinsic-id/okapi/go/okapiproto"
55
)
66

7+
// DidCommer implements the DIDComm Messaging protocol
78
type DidCommer interface {
89
Pack(request *okapiproto.PackRequest) (*okapiproto.PackResponse, error)
910
Unpack(request *okapiproto.UnpackRequest) (*okapiproto.UnpackResponse, error)
1011
Sign(request *okapiproto.SignRequest) (*okapiproto.SignResponse, error)
1112
Verify(request *okapiproto.VerifyRequest) (*okapiproto.VerifyResponse, error)
1213
}
1314

15+
// DidComm implements the DIDComm Messaging protocol
1416
func DidComm() DidCommer {
1517
return &didComm{}
1618
}

go/okapi/Hashing.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import (
44
"github.com/trinsic-id/okapi/go/okapiproto"
55
)
66

7+
// Hasher implements Blake3 and Sha2 hash functions
78
type Hasher interface {
89
Sha256Hash(request *okapiproto.SHA256HashRequest) (*okapiproto.SHA256HashResponse, error)
910
Blake3Hash(request *okapiproto.Blake3HashRequest) (*okapiproto.Blake3HashResponse, error)
1011
Blake3KeyedHash(request *okapiproto.Blake3KeyedHashRequest) (*okapiproto.Blake3KeyedHashResponse, error)
1112
Blake3DeriveKey(request *okapiproto.Blake3DeriveKeyRequest) (*okapiproto.Blake3DeriveKeyResponse, error)
1213
}
1314

15+
// Hashing implements Blake3 and Sha2 hash functions
1416
func Hashing() Hasher {
1517
return &hasher{}
1618
}

go/okapi/LdProofs.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package okapi
22

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

5+
// LdProofer implements Linked-Data Proofs
56
type LdProofer interface {
67
CreateProof(request *okapiproto.CreateProofRequest) (*okapiproto.CreateProofResponse, error)
78
VerifyProof(request *okapiproto.VerifyProofRequest) (*okapiproto.VerifyProofResponse, error)
89
}
910

11+
// LdProofs implements Linked-Data Proofs
1012
func LdProofs() LdProofer {
1113
return &ldProofs{}
1214
}

go/okapi/Oberon.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package okapi
22

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

5+
// Oberoner implements Oberon authentication
56
type Oberoner interface {
67
CreateKey(request *okapiproto.CreateOberonKeyRequest) (*okapiproto.CreateOberonKeyResponse, error)
78
CreateToken(request *okapiproto.CreateOberonTokenRequest) (*okapiproto.CreateOberonTokenResponse, error)
@@ -11,6 +12,7 @@ type Oberoner interface {
1112
VerifyProof(request *okapiproto.VerifyOberonProofRequest) (*okapiproto.VerifyOberonProofResponse, error)
1213
}
1314

15+
// Oberon implements Oberon authentication
1416
func Oberon() Oberoner {
1517
return &oberon{}
1618
}

go/okapi/native.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"unsafe"
1414
)
1515

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

26+
// DidError indicates a DID protocol error
2527
type DidError struct {
2628
Code int
2729
FunctionName string

0 commit comments

Comments
 (0)