diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index dff211c..62e1bd9 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -1,4 +1,5 @@ name: Astrolib Continuous Integration + on: push: @@ -7,43 +8,68 @@ jobs: name: lint runs-on: ubuntu-latest steps: - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v4 with: - go-version: 1.22 + go-version: 1.23 - uses: actions/checkout@v3 - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.56.2 + version: v1.60.3 args: --verbose test: strategy: matrix: - go-version: [1.22] + go-version: [1.23] platform: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.platform }} + env: + COVER_DIR: ${{ github.workspace }}/coverage + COVER_FILE: coverage.out + COVER_OUT_PATH: ${{ github.workspace }}/coverage/coverage.out + COVER_HTML_PATH: ${{ github.workspace }}/coverage/coverage.html + GINKGO_REPORT: ginkgo.report + steps: - name: Install Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} - name: Install goveralls run: go install github.com/mattn/goveralls@latest + - name: Install ginkgo + run: go install github.com/onsi/ginkgo/v2/ginkgo@v2.20.2 + - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - run: go test -v -coverprofile=coverage.out ./... + - name: Ensure coverage directory exists + run: | + mkdir -p ${{ github.workspace }}/coverage + + - name: Run tests and generate coverage profile with Ginkgo + run: | + ginkgo run -r -json-report {{env.GINKGO_REPORT}} -coverpkg=./... -coverprofile=coverage.out - - uses: shogo82148/actions-goveralls@v1 + - name: Apply coverage exclusions + run: | + ${{ github.workspace }}/scripts/apply-coverage-exclusions.sh + + - name: Check coverage directory contents + run: | + echo "Contents of ${{ github.workspace }}/coverage:" + ls -la ${{ github.workspace }}/coverage + + - name: Generate HTML coverage report + run: | + go tool cover -html=coverage.out -o ${{ github.workspace }}/coverage/coverage.html + + - name: Upload coverage to Coveralls + uses: shogo82148/actions-goveralls@v1 with: path-to-profile: coverage.out - - - name: Send coverage - env: - COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: goveralls -coverprofile=coverage.out -service=github diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml index de8b14f..22ec830 100644 --- a/.github/workflows/release-workflow.yml +++ b/.github/workflows/release-workflow.yml @@ -23,7 +23,7 @@ jobs: - name: Setup uses: actions/setup-go@v3 with: - go-version: '>=1.22' + go-version: '>=1.23' cache: true - name: Generate Changelog Only uses: goreleaser/goreleaser-action@v4 diff --git a/.golangci.yml b/.golangci.yml index 7ab8a5f..7ac922c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -12,7 +12,7 @@ linters-settings: - performance - style govet: - check-shadowing: true + shadow: true disable: - fieldalignment # too strict @@ -28,22 +28,22 @@ linters: # it can be re-enabled. # https://github.com/OpenPeeDeeP/depguard#example-configs # - depguard + - copyloopvar - dogsled # - dupl - errcheck - - exportloopref - exhaustive - goconst - gocritic - gofmt - goimports - - gomnd - gocyclo - gosec - gosimple - govet - ineffassign - misspell + - mnd - nolintlint - nakedret - prealloc diff --git a/.vscode/settings.json b/.vscode/settings.json index 8da9619..9cd417a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,6 +7,7 @@ "astrolib", "bodyclose", "cmds", + "copyloopvar", "coverpkg", "coverprofile", "cubiest", @@ -17,7 +18,6 @@ "dupl", "errcheck", "exportloopref", - "extendio", "fieldalignment", "goconst", "gocritic", @@ -38,6 +38,7 @@ "linters", "mattn", "nakedret", + "nicksnyder", "nolint", "nolintlint", "onsi", @@ -47,6 +48,7 @@ "repotoken", "shogo", "sidewalk", + "snivilised", "staticcheck", "structcheck", "stylecheck", diff --git a/go.mod b/go.mod index 3735d96..fa58371 100644 --- a/go.mod +++ b/go.mod @@ -1,27 +1,26 @@ module github.com/snivilised/astrolib -go 1.22.0 +go 1.23.0 require ( + github.com/nicksnyder/go-i18n/v2 v2.4.1 github.com/onsi/ginkgo/v2 v2.20.2 github.com/onsi/gomega v1.34.2 - github.com/snivilised/extendio v0.7.0 + github.com/snivilised/li18ngo v0.1.7 ) require ( - github.com/avfs/avfs v0.33.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 // indirect - github.com/kr/pretty v0.3.1 // indirect - github.com/nicksnyder/go-i18n/v2 v2.4.0 // indirect + github.com/google/pprof v0.0.0-20241023014458-598669927662 // indirect + github.com/kr/text v0.2.0 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/samber/lo v1.39.0 // indirect - golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect - golang.org/x/net v0.28.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/text v0.17.0 // indirect - golang.org/x/tools v0.24.0 // indirect + github.com/snivilised/nefilim v0.1.4 // indirect + golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect + golang.org/x/net v0.30.0 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/text v0.19.0 // indirect + golang.org/x/tools v0.26.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index da73119..3bfb519 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ -github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= -github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= -github.com/avfs/avfs v0.33.0 h1:5WQXbUbr6VS7aani39ZN2Vrd/s3wLnyih1Sc4ExWTxs= -github.com/avfs/avfs v0.33.0/go.mod h1:Q59flcFRYe9KYkNMfrLUJney3yeKGQpcWRyxsDBW7vI= +github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= +github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -11,60 +9,44 @@ github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1v github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= 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-20240827171923-fa2c70bbbfe5 h1:5iH8iuqE5apketRbSFBy+X1V0o+l+8NF1avt4HWl7cA= -github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= -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/google/pprof v0.0.0-20241023014458-598669927662 h1:SKMkD83p7FwUqKmBsPdLHF5dNyxq3jOWwu9w9UyH5vA= +github.com/google/pprof v0.0.0-20241023014458-598669927662/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= -github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= -github.com/nicksnyder/go-i18n/v2 v2.4.0 h1:3IcvPOAvnCKwNm0TB0dLDTuawWEj+ax/RERNC+diLMM= -github.com/nicksnyder/go-i18n/v2 v2.4.0/go.mod h1:nxYSZE9M0bf3Y70gPQjN9ha7XNHX7gMc814+6wVyEI4= +github.com/nicksnyder/go-i18n/v2 v2.4.1 h1:zwzjtX4uYyiaU02K5Ia3zSkpJZrByARkRB4V3YPrr0g= +github.com/nicksnyder/go-i18n/v2 v2.4.1/go.mod h1:++Pl70FR6Cki7hdzZRnEEqdc2dJt+SAGotyFg/SvZMk= github.com/onsi/ginkgo/v2 v2.20.2 h1:7NVCeyIWROIAheY21RLS+3j2bb52W0W82tkberYytp4= github.com/onsi/ginkgo/v2 v2.20.2/go.mod h1:K9gyxPIlb+aIvnZ8bd9Ak+YP18w3APlR+5coaZoE2ag= github.com/onsi/gomega v1.34.2 h1:pNCwDkzrsv7MS9kpaQvVb1aVLahQXyJ/Tv5oAZMI3i8= github.com/onsi/gomega v1.34.2/go.mod h1:v1xfxRgk0KIsG+QOdm7p8UosrOzPYRo60fd3B/1Dukc= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= 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.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= -github.com/samber/lo v1.39.0 h1:4gTz1wUhNYLhFSKl6O+8peW0v2F4BCY034GRpU9WnuA= -github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA= -github.com/snivilised/extendio v0.7.0 h1:MY6w9qCK5wVEvP2WpMT5ywJwpDJe97WHDGuwrsTLpek= -github.com/snivilised/extendio v0.7.0/go.mod h1:l8MwJOy9ojMQYJrSKRbQS3WfDylevnRtBp/zwAmFEKc= -github.com/snivilised/lorax v0.5.2 h1:iReIJl63tydiPSSD0YzsNQFX1CctmvMkYx0aSxoZJKo= -github.com/snivilised/lorax v0.5.2/go.mod h1:7H1JPgSn4h4p8NSqfl64raacYefdm/FiFkfcZ51PVHY= +github.com/snivilised/li18ngo v0.1.7 h1:XRYpmP7jSAxzRyg5WH0PViFb9ycWGFcDkQQqd2GsjzQ= +github.com/snivilised/li18ngo v0.1.7/go.mod h1:NVOexqt/aIhnenNPQDqbJchLNte92io87j5o2l+HNqs= +github.com/snivilised/nefilim v0.1.4 h1:bhiENDl/T6ZQO146eF8UnxtXLQenSzEyjwuTeWScImw= +github.com/snivilised/nefilim v0.1.4/go.mod h1:+4/hKxgfvE8eNjLMJC+3ropEZSQuiR/NqfPtIuw7ZMw= 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/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.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= -go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -go.uber.org/zap/exp v0.2.0 h1:FtGenNNeCATRB3CmB/yEUnjEFeJWpB/pMcy7e2bKPYs= -go.uber.org/zap/exp v0.2.0/go.mod h1:t0gqAIdh1MfKv9EwN/dLwfZnJxe9ITAZN78HEWPFWDQ= -golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= -golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= -golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= -golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= +golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY= +golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= +golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/helpers/test-utilities.go b/internal/lab/test-utilities.go similarity index 98% rename from internal/helpers/test-utilities.go rename to internal/lab/test-utilities.go index 2111a9f..52fa034 100644 --- a/internal/helpers/test-utilities.go +++ b/internal/lab/test-utilities.go @@ -1,4 +1,4 @@ -package helpers +package lab import ( "fmt" diff --git a/locale/i18n_suite_test.go b/locale/locale-suite_test.go similarity index 76% rename from locale/i18n_suite_test.go rename to locale/locale-suite_test.go index fae3007..23aeb9d 100644 --- a/locale/i18n_suite_test.go +++ b/locale/locale-suite_test.go @@ -7,7 +7,7 @@ import ( . "github.com/onsi/gomega" //nolint:revive // gomega ok ) -func TestI18n(t *testing.T) { +func TestLocale(t *testing.T) { RegisterFailHandler(Fail) - RunSpecs(t, "I18n Suite") + RunSpecs(t, "Locale Suite") } diff --git a/locale/messages-errors.go b/locale/messages-errors.go index bbc1718..861a6ce 100644 --- a/locale/messages-errors.go +++ b/locale/messages-errors.go @@ -1,14 +1,15 @@ package locale import ( - "github.com/snivilised/extendio/i18n" + "github.com/nicksnyder/go-i18n/v2/i18n" + "github.com/snivilised/li18ngo" ) // ❌ FooBar // FooBarTemplData - TODO: this is a none existent error that should be // replaced by the client. Its just defined here to illustrate the pattern -// that should be used to implement i18n with extendio. Also note, +// that should be used to implement i18n with li18ngo. Also note, // that this message has been removed from the translation files, so // it is not useable at run time. type FooBarTemplData struct { @@ -27,14 +28,8 @@ func (td FooBarTemplData) Message() *i18n.Message { } } -// FooBarErrorBehaviourQuery used to query if an error is: -// "Failed to read directory contents from the path specified" -type FooBarErrorBehaviourQuery interface { - FooBar() bool -} - type FooBarError struct { - i18n.LocalisableError + li18ngo.LocalisableError } // FooBar enables the client to check if error is FooBarError @@ -46,7 +41,7 @@ func (e FooBarError) FooBar() bool { // NewFooBarError creates a FooBarError func NewFooBarError(path string, reason error) FooBarError { return FooBarError{ - LocalisableError: i18n.LocalisableError{ + LocalisableError: li18ngo.LocalisableError{ Data: FooBarTemplData{ Path: path, Reason: reason, diff --git a/locale/messages-general.go b/locale/messages-general.go index d08071a..3614a5a 100644 --- a/locale/messages-general.go +++ b/locale/messages-general.go @@ -1,7 +1,7 @@ package locale import ( - "github.com/snivilised/extendio/i18n" + "github.com/nicksnyder/go-i18n/v2/i18n" ) type UsingConfigFileTemplData struct { diff --git a/locale/test-i18n-messages_test.go b/locale/test-i18n-messages_test.go index acf1b3c..d12c076 100644 --- a/locale/test-i18n-messages_test.go +++ b/locale/test-i18n-messages_test.go @@ -1,7 +1,7 @@ package locale_test import ( - "github.com/snivilised/extendio/i18n" + "github.com/nicksnyder/go-i18n/v2/i18n" ) const ( diff --git a/scripts/apply-coverage-exclusions.sh b/scripts/apply-coverage-exclusions.sh new file mode 100755 index 0000000..9f3c6d6 --- /dev/null +++ b/scripts/apply-coverage-exclusions.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Define paths relative to the root directory +ROOT_DIR="$(git rev-parse --show-toplevel)" +COVERAGE_FILE="$ROOT_DIR/coverage.out" +EXCLUSIONS_FILE="$ROOT_DIR/scripts/coverage-exclusion-list.txt" + +# Check if required files exist +if [ ! -f "$COVERAGE_FILE" ]; then + echo "Error: Coverage file not found at $COVERAGE_FILE" + exit 1 +fi + +if [ ! -f "$EXCLUSIONS_FILE" ]; then + echo "Error: Exclusions file not found at $EXCLUSIONS_FILE" + exit 1 +fi + +# Create a temporary file +TEMP_FILE=$(mktemp) + +# Process the exclusions +while IFS= read -r line || [[ -n "$line" ]]; do + # Escape special characters in the line for use in sed + escaped_line=$(echo "$line" | sed 's/[\/&]/\\&/g') + + # Remove matching lines from the coverage file + sed "/${escaped_line}/d" "$COVERAGE_FILE" > "$TEMP_FILE" + + # Replace the original file with the modified content + mv "$TEMP_FILE" "$COVERAGE_FILE" +done < "$EXCLUSIONS_FILE" + +echo "Coverage exclusions have been applied successfully." diff --git a/scripts/coverage-exclusion-list.txt b/scripts/coverage-exclusion-list.txt new file mode 100644 index 0000000..fa1a3ad --- /dev/null +++ b/scripts/coverage-exclusion-list.txt @@ -0,0 +1 @@ +github.com/snivilised/astrolib/internal/third