Skip to content

Commit

Permalink
ci: Optimize GitHub actions and update Go versions. (#274)
Browse files Browse the repository at this point in the history
* ci: Optimize GitHub actions and update Go versions.

- Add GitHub actions for unit testing, linting, building, and releasing
- Use a matrix strategy to test on different versions and platforms
- Update setup-go and go-version options for compatibility
- Format code and build zip files for different operating systems
- Upload releases to GitHub with specific asset names and types

* fix: Refactor item file naming convention

- Update `filename()` function to return `UnsupportedItem` in specific cases
- Replace `UnknownItem` with `UnsupportedItem` in `Filename` method of `Item` struct
- Refactor code for clarity and consistency

* ci: Update GitHub workflow with latest setup-go version

- Update setup-go action to v3 in lint.yml GitHub workflow
- Omits some big changes in file diff summary
- Improve overall workflow reliability and efficiency

* ci: Improve GitHub actions across platforms

- Improve Windows compatibility in build workflow
- Optimize unit testing for pull requests
- Upgrade Coveralls GitHub action to v2 for improved coverage tracking

* build: Optimize build process for consistency and efficiency

- Ensure consistency of line endings by disabling Git's automatic conversion
- Add format check for Windows systems
- Update Go version in strategy matrix to `1.21.x`
- Remove unused dependencies from build process
- Include all packages in repository in build command

* ci: Refactor GitHub workflow configuration

- Remove unnecessary checks for `windows-latest` in github workflow
- Change `gofmt` check to `diff` for formatting
- Remove unneeded Git configuration for encoding of line endings
- Close #273
  • Loading branch information
moonD4rk authored Jan 12, 2024
1 parent a721191 commit 268a5eb
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 27 deletions.
52 changes: 30 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
name: build

on:
push:
branches:
- master
pull_request:

jobs:
build:
name: Build
runs-on: ubuntu-latest
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
goVer: ["1.21"]
os: [ubuntu-latest, windows-latest, macos-latest]
goVer: ["1.21.x"]

steps:
- name: Set up Go ${{ matrix.goVer }}
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.goVer }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: |
go get -v -t -d ./...
go get gopkg.in/check.v1
- name: Format
run: diff -u <(echo -n) <(gofmt -d .)

- name: Build
run: go build -v ./...
- name: Set up Go ${{ matrix.goVer }}
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.goVer }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Set Git to handle line endings consistently
run: git config --global core.autocrlf false

- name: Format Check
if: matrix.os != 'windows-latest'
run: |
diff -u <(echo -n) <(gofmt -d .)
- name: Get dependencies
run: |
go get -v -t -d ./...
go get gopkg.in/check.v1
- name: Build
run: go build -v ./...
3 changes: 1 addition & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
branches:
- master
pull_request:

jobs:
lint:
name: Lint
Expand All @@ -13,7 +12,7 @@ jobs:
- name: Set Golang
uses: actions/setup-go@v3
with:
go-version: "1.21"
go-version: "1.21.x"
- name: Checkout code
uses: actions/checkout@v3
- name: Lint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Use Golang
uses: actions/setup-go@v3
with:
go-version: "1.21"
go-version: "1.21.x"

- name: Build with xgo
uses: crazy-max/ghaction-xgo@v2
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
on:
[pull_request]

name: run tests
jobs:
test:
strategy:
matrix:
go-version: [ "1.21.x" ]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
if: success()
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Run tests
run: go test -v ./... -covermode=count

coverage:
runs-on: ubuntu-latest
steps:
- name: Install Go
if: success()
uses: actions/setup-go@v3
with:
go-version: "1.21.x"
- name: Checkout code
uses: actions/checkout@v2
- name: Calc coverage
run: |
go test -v ./... -covermode=count -coverprofile=coverage.out
- name: Convert coverage.out to coverage.lcov
uses: jandelgado/gcov2lcov-action@v1
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: coverage.lcov
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,6 @@ hack-browser-data
!/browsingdata/history
!/browsingdata/history/history.go
!/browsingdata/history/history_test.go

# github action
!/.github/workflows/unittest.yml
2 changes: 1 addition & 1 deletion item/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (i Item) Filename() string {
if fileName, ok := itemFileNames[i]; ok {
return fileName
}
return UnknownItem
return UnsupportedItem
}

const tempSuffix = "temp"
Expand Down
2 changes: 1 addition & 1 deletion item/item_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ func (i Item) filename() string {
case FirefoxCreditCard:
return UnsupportedItem
default:
return UnknownItem
return UnsupportedItem
}
}

0 comments on commit 268a5eb

Please sign in to comment.