mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-15 02:12: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']
|
go: ['1.23']
|
||||||
env:
|
env:
|
||||||
PERFORM_ONLINE_TEST: ${{ vars.PERFORM_ONLINE_TEST }}
|
PERFORM_ONLINE_TEST: ${{ vars.PERFORM_ONLINE_TEST }}
|
||||||
|
TEST_SENDMAIL: ${{ vars.TEST_SENDMAIL }}
|
||||||
TEST_HOST: ${{ secrets.TEST_HOST }}
|
TEST_HOST: ${{ secrets.TEST_HOST }}
|
||||||
TEST_USER: ${{ secrets.TEST_USER }}
|
TEST_USER: ${{ secrets.TEST_USER }}
|
||||||
TEST_PASS: ${{ secrets.TEST_PASS }}
|
TEST_PASS: ${{ secrets.TEST_PASS }}
|
||||||
|
@ -48,8 +49,9 @@ jobs:
|
||||||
check-latest: true
|
check-latest: true
|
||||||
- name: Install sendmail
|
- name: Install sendmail
|
||||||
run: |
|
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
|
- name: Run go test
|
||||||
|
if: success()
|
||||||
run: |
|
run: |
|
||||||
go test -race -shuffle=on --coverprofile=coverage.coverprofile --covermode=atomic ./...
|
go test -race -shuffle=on --coverprofile=coverage.coverprofile --covermode=atomic ./...
|
||||||
- name: Upload coverage to Codecov
|
- name: Upload coverage to Codecov
|
||||||
|
@ -176,9 +178,6 @@ jobs:
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
check-latest: true
|
check-latest: true
|
||||||
- name: Install sendmail
|
|
||||||
run: |
|
|
||||||
sudo apt-get -y install sendmail; which sendmail
|
|
||||||
- name: Run go test
|
- name: Run go test
|
||||||
run: |
|
run: |
|
||||||
go test -shuffle=on -race --coverprofile=./cov.out ./...
|
go test -shuffle=on -race --coverprofile=./cov.out ./...
|
||||||
|
|
|
@ -16,8 +16,8 @@ import (
|
||||||
|
|
||||||
// TestMsg_WriteToSendmailWithContext tests the WriteToSendmailWithContext() method of the Msg
|
// TestMsg_WriteToSendmailWithContext tests the WriteToSendmailWithContext() method of the Msg
|
||||||
func TestMsg_WriteToSendmailWithContext(t *testing.T) {
|
func TestMsg_WriteToSendmailWithContext(t *testing.T) {
|
||||||
if os.Getenv("TEST_SKIP_SENDMAIL") != "" {
|
if os.Getenv("TEST_SENDMAIL") != "true" {
|
||||||
t.Skipf("TEST_SKIP_SENDMAIL variable is set. Skipping sendmail test")
|
t.Skipf("TEST_SENDMAIL variable is not set. Skipping sendmail test")
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
@ -45,8 +45,8 @@ func TestMsg_WriteToSendmailWithContext(t *testing.T) {
|
||||||
|
|
||||||
// TestMsg_WriteToSendmail will test the output to the local sendmail command
|
// TestMsg_WriteToSendmail will test the output to the local sendmail command
|
||||||
func TestMsg_WriteToSendmail(t *testing.T) {
|
func TestMsg_WriteToSendmail(t *testing.T) {
|
||||||
if os.Getenv("TEST_SKIP_SENDMAIL") != "" {
|
if os.Getenv("TEST_SENDMAIL") != "true" {
|
||||||
t.Skipf("TEST_SKIP_SENDMAIL variable is set. Skipping sendmail test")
|
t.Skipf("TEST_SENDMAIL variable is not set. Skipping sendmail test")
|
||||||
}
|
}
|
||||||
_, err := os.Stat(SendmailPath)
|
_, err := os.Stat(SendmailPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue