Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add github actions #1

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider optimizing job configurations to reduce repetition.

The setup steps are repeated across all three jobs. Consider creating a composite action or using a matrix strategy to reduce duplication and improve maintainability.

name: Build and Test

on:
  pull_request:
    branches: [main]

jobs:
  build-and-test:
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v3
      - name: Set up environment
        uses: ./.github/actions/setup-env
      - name: Build and test
        run: |
          npm ci
          npm run build
          npm test


on: [pull_request]

jobs:
unit-tests:
name: vet and test
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.12
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): Consider upgrading Go version from 1.12 to a more recent stable version.

Using an outdated Go version may miss out on performance improvements, bug fixes, and new language features. It's recommended to use a more recent stable version across all jobs.

Suggested change
go-version: 1.12
go-version: '1.21'

- uses: actions/checkout@v2
with:
path: src/github.com/go-ping/ping
- run: |
export GOPATH=$GITHUB_WORKSPACE
cd $GITHUB_WORKSPACE/src/github.com/go-ping/ping
go get ./...
go vet ./...
go test ./... -cover -race

build-ping-cmd:
name: build ping command and run
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.12
- uses: actions/checkout@v2
with:
path: src/github.com/go-ping/ping
- run: |
export GOPATH=$GITHUB_WORKSPACE
cd $GITHUB_WORKSPACE/src/github.com/go-ping/ping
go build -race -o ping_linux ./cmd/ping/ping.go
sudo ./ping_linux --privileged -c 2 www.google.com
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 suggestion (security): Document the need for sudo privileges in the build-ping-cmd job.

Running the built binary with sudo privileges may be necessary for ICMP packets, but it has security implications. Consider adding a comment explaining why this is required.

Suggested change
sudo ./ping_linux --privileged -c 2 www.google.com
# Elevated privileges required for ICMP packets
sudo ./ping_linux --privileged -c 2 www.google.com

sudo ./ping_linux --privileged -c 3 -i 200ms www.google.com
sudo ./ping_linux --privileged -c 10 -i 100ms -t 1s www.google.com

x-platform-build:
name: cross platform build
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.12
- uses: actions/checkout@v2
with:
path: src/github.com/aws/amazon-ecs-agent
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (typo): Correct the checkout path in the x-platform-build job.

The checkout path in this job differs from the others, using 'aws/amazon-ecs-agent' instead of 'go-ping/ping'. This appears to be a copy-paste error that should be fixed.

- run: |
export GOPATH=$GITHUB_WORKSPACE
cd $GITHUB_WORKSPACE/src/github.com/go-ping/ping
GOOS=darwin go build -o ping_darwin ./cmd/ping/ping.go
Loading