Skip to content

Commit

Permalink
Update CI workflow and sendmail test condition
Browse files Browse the repository at this point in the history
Add the TEST_SENDMAIL environment variable for better control over sendmail tests. Optimize sendmail installation in CI by updating and installing ssmtp. Modify tests to check if TEST_SENDMAIL is set to "true" before running.
  • Loading branch information
wneessen committed Oct 26, 2024
1 parent 9072aef commit 4b8bf05
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
go: ['1.23']
env:
PERFORM_ONLINE_TEST: ${{ vars.PERFORM_ONLINE_TEST }}
TEST_SENDMAIL: ${{ vars.TEST_SENDMAIL }}
TEST_HOST: ${{ secrets.TEST_HOST }}
TEST_USER: ${{ secrets.TEST_USER }}
TEST_PASS: ${{ secrets.TEST_PASS }}
Expand All @@ -48,8 +49,9 @@ jobs:
check-latest: true
- name: Install sendmail
run: |
sudo apt-get -y install sendmail; which sendmail
apt-get -y update >/dev/null && apt-get -y upgrade >/dev/null && apt-get -y install ssmtp >/dev/null && which sendmail
- name: Run go test
if: success()
run: |
go test -race -shuffle=on --coverprofile=coverage.coverprofile --covermode=atomic ./...
- name: Upload coverage to Codecov
Expand Down Expand Up @@ -176,9 +178,6 @@ jobs:
with:
go-version: ${{ matrix.go }}
check-latest: true
- name: Install sendmail
run: |
sudo apt-get -y install sendmail; which sendmail
- name: Run go test
run: |
go test -shuffle=on -race --coverprofile=./cov.out ./...
Expand Down
8 changes: 4 additions & 4 deletions msg_nowin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (

// TestMsg_WriteToSendmailWithContext tests the WriteToSendmailWithContext() method of the Msg
func TestMsg_WriteToSendmailWithContext(t *testing.T) {
if os.Getenv("TEST_SKIP_SENDMAIL") != "" {
t.Skipf("TEST_SKIP_SENDMAIL variable is set. Skipping sendmail test")
if os.Getenv("TEST_SENDMAIL") != "true" {
t.Skipf("TEST_SENDMAIL variable is not set. Skipping sendmail test")
}
tests := []struct {
name string
Expand Down Expand Up @@ -45,8 +45,8 @@ func TestMsg_WriteToSendmailWithContext(t *testing.T) {

// TestMsg_WriteToSendmail will test the output to the local sendmail command
func TestMsg_WriteToSendmail(t *testing.T) {
if os.Getenv("TEST_SKIP_SENDMAIL") != "" {
t.Skipf("TEST_SKIP_SENDMAIL variable is set. Skipping sendmail test")
if os.Getenv("TEST_SENDMAIL") != "true" {
t.Skipf("TEST_SENDMAIL variable is not set. Skipping sendmail test")
}
_, err := os.Stat(SendmailPath)
if err != nil {
Expand Down

0 comments on commit 4b8bf05

Please sign in to comment.