-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
151 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,25 @@ jobs: | |
run: | | ||
go install github.com/golangci/golangci-lint/cmd/[email protected] | ||
golangci-lint run | ||
- name: Package | ||
run: ./build.sh && ./package.sh | ||
- name: Upload packages | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: packages | ||
path: build/packages/ | ||
if-no-files-found: error | ||
|
||
test_linux: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22.2' | ||
cache: true | ||
- name: Test | ||
run: go test -coverprofile="coverage.out" -coverpkg "$(go list github.com/UiPath/uipathcli/... | grep -v 'test' | tr '\n' ',')" ./... | ||
- name: Coverage | ||
|
@@ -41,17 +60,22 @@ jobs: | |
run: | | ||
go install github.com/mattn/goveralls@latest | ||
goveralls -coverprofile="coverage.out" -service="github" | ||
- name: Package | ||
run: ./build.sh && ./package.sh | ||
- name: Upload packages | ||
uses: actions/upload-artifact@v4 | ||
test_windows: | ||
runs-on: windows-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup go | ||
uses: actions/setup-go@v5 | ||
with: | ||
name: packages | ||
path: build/packages/ | ||
if-no-files-found: error | ||
go-version: '1.22.2' | ||
cache: true | ||
- name: Test | ||
run: go test ./... | ||
|
||
publish_pages: | ||
needs: build | ||
needs: [build, test_linux, test_windows] | ||
permissions: | ||
pages: write | ||
id-token: write | ||
|
@@ -79,7 +103,7 @@ jobs: | |
uses: actions/deploy-pages@v4 | ||
|
||
release: | ||
needs: build | ||
needs: [build, test_linux, test_windows] | ||
if: github.ref == 'refs/heads/main' | ||
runs-on: ubuntu-latest | ||
env: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
//go:build windows | ||
|
||
package studio | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
"path/filepath" | ||
"runtime" | ||
"testing" | ||
|
||
"github.com/UiPath/uipathcli/test" | ||
) | ||
|
||
const emptyStudioDefinition = ` | ||
openapi: 3.0.1 | ||
info: | ||
title: UiPath Studio | ||
description: UiPath Studio | ||
version: v1 | ||
servers: | ||
- url: https://cloud.uipath.com/{organization}/studio_/backend | ||
description: The production url | ||
variables: | ||
organization: | ||
description: The organization name (or id) | ||
default: my-org | ||
paths: | ||
{} | ||
` | ||
|
||
func TestPackWindowsSuccessfully(t *testing.T) { | ||
context := test.NewContextBuilder(). | ||
WithDefinition("studio", emptyStudioDefinition). | ||
WithCommandPlugin(NewPackagePackCommand()). | ||
Build() | ||
|
||
source := studioWindowsProjectDirectory() | ||
destination := createTempDirectory(t) | ||
result := test.RunCli([]string{"studio", "package", "pack", "--source", source, "--destination", destination}, context) | ||
|
||
stdout := map[string]interface{}{} | ||
err := json.Unmarshal([]byte(result.StdOut), &stdout) | ||
if err != nil { | ||
t.Errorf("Failed to deserialize pack command result: %v", err) | ||
} | ||
if stdout["status"] != "Succeeded" { | ||
t.Errorf("Expected status to be Succeeded, but got: %v", result.StdOut) | ||
} | ||
if stdout["error"] != nil { | ||
t.Errorf("Expected error to be nil, but got: %v", result.StdOut) | ||
} | ||
if stdout["name"] != "MyWindowsProcess" { | ||
t.Errorf("Expected name to be set, but got: %v", result.StdOut) | ||
} | ||
if stdout["description"] != "Blank Process" { | ||
t.Errorf("Expected version to be set, but got: %v", result.StdOut) | ||
} | ||
if stdout["projectId"] != "94c4c9c1-68c3-45d4-be14-d4427f17eddd" { | ||
t.Errorf("Expected projectId to be set, but got: %v", result.StdOut) | ||
} | ||
if stdout["version"] != "1.0.0" { | ||
t.Errorf("Expected version to be set, but got: %v", result.StdOut) | ||
} | ||
outputFile := stdout["output"].(string) | ||
if outputFile != filepath.Join(destination, "MyWindowsProcess.1.0.0.nupkg") { | ||
t.Errorf("Expected output path to be set, but got: %v", result.StdOut) | ||
} | ||
if _, err := os.Stat(outputFile); err != nil { | ||
t.Errorf("Expected output file %s to exists, but could not find it: %v", outputFile, err) | ||
} | ||
} | ||
|
||
func TestAnalyzeWindowsSuccessfully(t *testing.T) { | ||
context := test.NewContextBuilder(). | ||
WithDefinition("studio", emptyStudioDefinition). | ||
WithCommandPlugin(NewPackageAnalyzeCommand()). | ||
Build() | ||
|
||
source := studioWindowsProjectDirectory() | ||
result := test.RunCli([]string{"studio", "package", "analyze", "--source", source}, context) | ||
|
||
stdout := map[string]interface{}{} | ||
err := json.Unmarshal([]byte(result.StdOut), &stdout) | ||
if err != nil { | ||
t.Errorf("Failed to deserialize analyze command result: %v", err) | ||
} | ||
if stdout["status"] != "Succeeded" { | ||
t.Errorf("Expected status to be Succeeded, but got: %v", result.StdOut) | ||
} | ||
if stdout["error"] != nil { | ||
t.Errorf("Expected error to be nil, but got: %v", result.StdOut) | ||
} | ||
violations := stdout["violations"].([]interface{}) | ||
if len(violations) == 0 { | ||
t.Errorf("Expected violations not to be empty, but got: %v", result.StdOut) | ||
} | ||
} | ||
|
||
func studioWindowsProjectDirectory() string { | ||
_, filename, _, _ := runtime.Caller(0) | ||
return filepath.Join(filepath.Dir(filename), "projects", "windows") | ||
} | ||
|
||
func createTempDirectory(t *testing.T) string { | ||
tmp, err := os.MkdirTemp("", "uipath-test") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
t.Cleanup(func() { os.RemoveAll(tmp) }) | ||
return tmp | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters