mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-14 18:02:55 +01:00
Update CI workflow and sendmail test condition
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.
This commit is contained in:
parent
9072aef355
commit
4b8bf0507d
2 changed files with 7 additions and 8 deletions
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
|
@ -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 }}
|
||||
|
@ -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
|
||||
|
@ -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 ./...
|
||||
|
|
|
@ -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
|
||||
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue