-
Notifications
You must be signed in to change notification settings - Fork 0
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
Nikita Sharaev
committed
Feb 11, 2024
1 parent
c25c9b8
commit 71c7ef1
Showing
34 changed files
with
2,868 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
name: basic | ||
on: | ||
pull_request: | ||
types: [opened, reopened] | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@master | ||
- name: Setup Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.21 | ||
- name: Test | ||
run: make test | ||
- name: "Fmt, Vet, and Build" | ||
run: make bin |
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,23 @@ | ||
--- | ||
name: release | ||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@master | ||
- name: Setup Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.21 | ||
- name: GoReleaser | ||
uses: goreleaser/goreleaser-action@v1 | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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 |
---|---|---|
|
@@ -19,3 +19,8 @@ | |
|
||
# Go workspace file | ||
go.work | ||
coverage.out | ||
.history/ | ||
bin/ | ||
report.json | ||
allure-results/ |
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,21 @@ | ||
export GO111MODULE=on | ||
|
||
.PHONY: bin | ||
bin: fmt vet | ||
go build -o bin/ginkgo2allure github.com/Moon1706/ginkgo2allure | ||
|
||
.PHONY: fmt | ||
fmt: | ||
go fmt ./... | ||
|
||
.PHONY: vet | ||
vet: | ||
go vet ./... | ||
|
||
.PHONY: test | ||
test: | ||
go test --short --count=1 --covermode=count --coverprofile=coverage.out --coverpkg=./... ./... | ||
|
||
.PHONY: coverage | ||
coverage: test | ||
go tool cover --func=coverage.out |
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,95 @@ | ||
package cmd | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/Moon1706/ginkgo2allure/internal/app" | ||
"github.com/Moon1706/ginkgo2allure/pkg/convert/parser" | ||
"github.com/Moon1706/ginkgo2allure/pkg/convert/report" | ||
"github.com/Moon1706/ginkgo2allure/pkg/convert/transform" | ||
"github.com/spf13/cobra" | ||
"go.uber.org/zap" | ||
"go.uber.org/zap/zapcore" | ||
) | ||
|
||
const ( | ||
CountArgs = 2 | ||
CountAnalyzeErrorsArgs = 2 | ||
|
||
FlagEpic = "epic" | ||
FlagLabelSeparator = "label_separator" | ||
FlagMandatoryLabels = "mandatory_labels" | ||
FlagAnalyzeErrors = "analyze_errors" | ||
FlagLogLevel = "log_level" | ||
) | ||
|
||
var ( | ||
logLevel string | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "ginkgo2allure ./ginkgo-report.json ./save/allure/reports/folder/path/", | ||
Short: "Convert Ginkgo report to Allure report", | ||
Long: `Prototype of a tool that converts Ginkgo JSON reports to Allure JSON reports | ||
in a separate folder allure-results.`, | ||
Args: cobra.MatchAll(cobra.ExactArgs(CountArgs), cobra.OnlyValidArgs), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
config := parser.Config{} | ||
logger, err := buildLogger(logLevel) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
epic, err := cmd.Flags().GetString(FlagEpic) | ||
if err == nil && epic != "" { | ||
config.LabelsScraperOpts = append(config.LabelsScraperOpts, report.WithEpic(epic)) | ||
} | ||
labelSpliter, err := cmd.Flags().GetString(FlagLabelSeparator) | ||
if err == nil && labelSpliter != "" { | ||
config.LabelsScraperOpts = append(config.LabelsScraperOpts, report.WithLabelSpliter(labelSpliter)) | ||
} | ||
mandatoryLabels, err := cmd.Flags().GetStringSlice(FlagMandatoryLabels) | ||
if err == nil && len(mandatoryLabels) != 0 { | ||
config.ReportOpts = append(config.ReportOpts, report.WithMandatoryLabels(mandatoryLabels)) | ||
} | ||
analyzeErrors, err := cmd.Flags().GetBool(FlagAnalyzeErrors) | ||
if err == nil { | ||
config.TransformOpts = append(config.TransformOpts, transform.WillAnalyzeErrors(analyzeErrors, analyzeErrors)) | ||
} | ||
app.StartConvertion(args[0], args[1], config, logger) | ||
}, | ||
} | ||
|
||
func ExecuteContext(ctx context.Context) { | ||
if err := rootCmd.ExecuteContext(ctx); err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func init() { | ||
rootCmd.Flags().StringP(FlagEpic, "e", report.DefaultEpic, "epic name") | ||
rootCmd.Flags().String(FlagLabelSeparator, report.DefaultLabelSpliter, "labels separator") | ||
rootCmd.Flags().StringSlice(FlagMandatoryLabels, []string{report.IDLabelName}, "allure mandatory labels") | ||
rootCmd.Flags().Bool(FlagAnalyzeErrors, true, "will analyze test fails in Ginkgo report or not") | ||
rootCmd.PersistentFlags().StringVarP(&logLevel, FlagLogLevel, "l", "info", "log level") | ||
} | ||
|
||
func buildLogger(logLevel string) (*zap.Logger, error) { | ||
lvl, err := zap.ParseAtomicLevel(logLevel) | ||
if err != nil { | ||
lvl = zap.NewAtomicLevelAt(zap.ErrorLevel) | ||
} | ||
|
||
encconf := zap.NewProductionEncoderConfig() | ||
encconf.TimeKey = "@timestamp" | ||
encconf.EncodeTime = zapcore.RFC3339TimeEncoder | ||
|
||
conf := zap.NewProductionConfig() | ||
conf.EncoderConfig = encconf | ||
conf.Level = lvl | ||
|
||
return conf.Build() | ||
} |
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,29 @@ | ||
module github.com/Moon1706/ginkgo2allure | ||
|
||
go 1.21 | ||
|
||
require ( | ||
github.com/google/uuid v1.6.0 | ||
github.com/onsi/ginkgo/v2 v2.15.0 | ||
github.com/ozontech/allure-go/pkg/allure v0.6.12 | ||
github.com/pkg/errors v0.9.1 | ||
github.com/spf13/cobra v1.8.0 | ||
github.com/stretchr/testify v1.8.4 | ||
go.uber.org/zap v1.26.0 | ||
) | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect | ||
github.com/go-logr/logr v1.4.1 // indirect | ||
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect | ||
github.com/inconshreveable/mousetrap v1.1.0 // indirect | ||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect | ||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
go.uber.org/goleak v1.3.0 // indirect | ||
go.uber.org/multierr v1.11.0 // indirect | ||
golang.org/x/sys v0.16.0 // indirect | ||
google.golang.org/protobuf v1.31.0 // indirect | ||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
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,70 @@ | ||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= | ||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= | ||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= | ||
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= | ||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= | ||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= | ||
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= | ||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= | ||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= | ||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= | ||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= | ||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= | ||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | ||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= | ||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= | ||
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= | ||
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= | ||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= | ||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= | ||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= | ||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= | ||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= | ||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= | ||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= | ||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= | ||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= | ||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= | ||
github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= | ||
github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= | ||
github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= | ||
github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= | ||
github.com/ozontech/allure-go/pkg/allure v0.6.12 h1:O9VTf7fW9q/c9qKidQ3CGRCXBC4c8MR7NZW+oVm7Uz4= | ||
github.com/ozontech/allure-go/pkg/allure v0.6.12/go.mod h1:4oEG2yq+DGOzJS/ZjPc87C/mx3tAnlYpYonk77Ru/vQ= | ||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= | ||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= | ||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= | ||
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= | ||
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= | ||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= | ||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= | ||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= | ||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | ||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= | ||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= | ||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= | ||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= | ||
go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= | ||
go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= | ||
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= | ||
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= | ||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= | ||
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= | ||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= | ||
golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= | ||
golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= | ||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= | ||
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= | ||
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= | ||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
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,42 @@ | ||
package app | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
|
||
"github.com/Moon1706/ginkgo2allure/pkg/convert" | ||
fmngr "github.com/Moon1706/ginkgo2allure/pkg/convert/file_manager" | ||
"github.com/Moon1706/ginkgo2allure/pkg/convert/parser" | ||
"github.com/onsi/ginkgo/v2/types" | ||
"go.uber.org/zap" | ||
) | ||
|
||
func StartConvertion(ginkgoReportFile, allureReportsFolder string, config parser.Config, logger *zap.Logger) { | ||
sugar := logger.Sugar() | ||
|
||
file, err := os.ReadFile(ginkgoReportFile) | ||
if err != nil { | ||
sugar.Fatal("Error reading file `%s`", ginkgoReportFile) | ||
} | ||
|
||
var ginkgoReport []types.Report | ||
err = json.Unmarshal(file, &ginkgoReport) | ||
if err != nil { | ||
sugar.Fatal("Error unmarshaling file `%s`", ginkgoReportFile) | ||
} | ||
|
||
allureReports, err := convert.GinkgoToAllureReport(ginkgoReport, parser.NewDefaultParser, | ||
config) | ||
if err != nil { | ||
sugar.Fatal("Error converting report `%s`", ginkgoReportFile) | ||
} | ||
|
||
fileManager := fmngr.NewFileManager(allureReportsFolder) | ||
errs := convert.PrintAllureReports(allureReports, fileManager) | ||
for _, err := range errs { | ||
sugar.Error(err) | ||
} | ||
if len(errs) != 0 { | ||
sugar.Fatal("Saving errors") | ||
} | ||
} |
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,30 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
|
||
"github.com/Moon1706/ginkgo2allure/cmd" | ||
) | ||
|
||
func main() { | ||
ctx := setupSignalHandler() | ||
cmd.ExecuteContext(ctx) | ||
} | ||
|
||
func setupSignalHandler() context.Context { | ||
shutdownSignals := []os.Signal{os.Interrupt, syscall.SIGTERM} | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
|
||
c := make(chan os.Signal, len(shutdownSignals)) | ||
signal.Notify(c, shutdownSignals...) | ||
go func() { | ||
<-c | ||
cancel() | ||
<-c | ||
os.Exit(1) | ||
}() | ||
return ctx | ||
} |
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,44 @@ | ||
package convert | ||
|
||
import ( | ||
fmngr "github.com/Moon1706/ginkgo2allure/pkg/convert/file_manager" | ||
"github.com/Moon1706/ginkgo2allure/pkg/convert/parser" | ||
"github.com/Moon1706/ginkgo2allure/pkg/convert/report" | ||
"github.com/onsi/ginkgo/v2/types" | ||
"github.com/ozontech/allure-go/pkg/allure" | ||
) | ||
|
||
func GinkgoToAllureReport(ginkgoReports []types.Report, parserCreation parser.CreationFunc, | ||
config parser.Config) ([]allure.Result, error) { | ||
results := []allure.Result{} | ||
for _, ginkgoReport := range ginkgoReports { | ||
suiteName := ginkgoReport.SuiteDescription | ||
for _, specReport := range ginkgoReport.SpecReports { | ||
if specReport.LeafNodeType != types.NodeTypeIt { | ||
continue | ||
} | ||
config.LabelsScraperOpts = append(config.LabelsScraperOpts, report.WithSuiteName(suiteName)) | ||
p, err := parserCreation(specReport, config) | ||
if err != nil { | ||
return results, err | ||
} | ||
result, err := p.GetAllureReport() | ||
if err != nil { | ||
return results, err | ||
} | ||
results = append(results, result) | ||
} | ||
} | ||
return results, nil | ||
} | ||
|
||
func PrintAllureReports(results []allure.Result, fm fmngr.FileManager) []error { | ||
errs := []error{} | ||
for _, result := range results { | ||
err := fm.SaveJSONResult(result) | ||
if err != nil { | ||
errs = append(errs, err) | ||
} | ||
} | ||
return errs | ||
} |
Oops, something went wrong.