Skip to content

Commit dc9d7d8

Browse files
committed
fix CI controls
1 parent 7345d2a commit dc9d7d8

File tree

2 files changed

+109
-29
lines changed

2 files changed

+109
-29
lines changed

.github/workflows/go.yml

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,28 +115,47 @@ jobs:
115115
ls -la dist/
116116
117117
echo -e "\n=== Validating Linux builds ==="
118-
if [ -f dist/*_linux_amd64.zip ]; then
119-
echo "✓ Linux amd64 zip found"
120-
file dist/*_linux_amd64.zip
121-
unzip -l dist/*_linux_amd64.zip | head -5
118+
if [ -d "dist/terraform-provider-wallix-bastion_linux_amd64_v1" ]; then
119+
echo "✓ Linux amd64 build directory found"
120+
ls -la "dist/terraform-provider-wallix-bastion_linux_amd64_v1/"
121+
122+
# Check if binary exists
123+
LINUX_BINARY=$(find "dist/terraform-provider-wallix-bastion_linux_amd64_v1" -name "*" -type f | head -1)
124+
if [ -n "$LINUX_BINARY" ]; then
125+
echo "✓ Linux binary found: $LINUX_BINARY"
126+
file "$LINUX_BINARY"
127+
ls -lh "$LINUX_BINARY"
128+
else
129+
echo "✗ No binary found in Linux build directory"
130+
exit 1
131+
fi
122132
else
123-
echo "✗ Linux amd64 zip not found"
133+
echo "✗ Linux amd64 build directory not found"
124134
exit 1
125135
fi
126136
127137
echo -e "\n=== Validating Windows builds ==="
128-
if [ -f dist/*_windows_amd64.zip ]; then
129-
echo "✓ Windows amd64 zip found"
130-
file dist/*_windows_amd64.zip
131-
unzip -l dist/*_windows_amd64.zip | head -10
138+
if [ -d "dist/terraform-provider-wallix-bastion_windows_amd64_v1" ]; then
139+
echo "✓ Windows amd64 build directory found"
140+
ls -la "dist/terraform-provider-wallix-bastion_windows_amd64_v1/"
141+
142+
# Check if binary exists
143+
WINDOWS_BINARY=$(find "dist/terraform-provider-wallix-bastion_windows_amd64_v1" -name "*" -type f | head -1)
144+
if [ -n "$WINDOWS_BINARY" ]; then
145+
echo "✓ Windows binary found: $WINDOWS_BINARY"
146+
file "$WINDOWS_BINARY"
147+
ls -lh "$WINDOWS_BINARY"
148+
else
149+
echo "✗ No binary found in Windows build directory"
150+
exit 1
151+
fi
132152
else
133-
echo "✗ Windows amd64 zip not found"
153+
echo "✗ Windows amd64 build directory not found"
134154
exit 1
135155
fi
136156
137157
echo -e "\n=== Testing binary execution ==="
138-
# Extract and test a binary
139-
LINUX_BINARY=$(find dist -name "*_linux_amd64" -type f | head -1)
158+
# Test Linux binary
140159
if [ -n "$LINUX_BINARY" ]; then
141160
echo "Testing binary: $LINUX_BINARY"
142161
chmod +x "$LINUX_BINARY"
@@ -147,4 +166,15 @@ jobs:
147166
fi
148167
fi
149168
169+
echo -e "\n=== Testing GoReleaser archive creation ==="
170+
# Test that GoReleaser can create archives (dry run)
171+
echo "Testing archive creation with GoReleaser..."
172+
if which goreleaser >/dev/null 2>&1; then
173+
# Check the config is valid
174+
goreleaser check
175+
echo "✓ GoReleaser configuration is valid"
176+
else
177+
echo "⚠ GoReleaser not available for config check"
178+
fi
179+
150180
echo -e "\n=== Build validation completed successfully! ==="

.github/workflows/release.yml

Lines changed: 67 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,37 +69,85 @@ jobs:
6969
mkdir -p /tmp/artifacts
7070
cd /tmp/artifacts
7171
72-
# Download key artifacts to validate
73-
echo "Downloading Linux amd64 zip..."
74-
curl -L -o "terraform-provider-wallix-bastion_${TAG}_linux_amd64.zip" \
75-
"https://github.com/wallix/terraform-provider-wallix-bastion/releases/download/${TAG}/terraform-provider-wallix-bastion_${TAG}_linux_amd64.zip"
72+
# Wait for release to be fully available
73+
echo "Waiting for release artifacts to be available..."
74+
sleep 30
7675
77-
echo "Downloading Windows amd64 zip..."
78-
curl -L -o "terraform-provider-wallix-bastion_${TAG}_windows_amd64.zip" \
79-
"https://github.com/wallix/terraform-provider-wallix-bastion/releases/download/${TAG}/terraform-provider-wallix-bastion_${TAG}_windows_amd64.zip"
76+
# Function to download with retries
77+
download_with_retry() {
78+
local url="$1"
79+
local filename="$2"
80+
local max_attempts=5
81+
local attempt=1
82+
83+
while [ $attempt -le $max_attempts ]; do
84+
echo "Attempt $attempt/$max_attempts: Downloading $filename..."
85+
if curl -L -f -o "$filename" "$url"; then
86+
# Check if we got an actual file, not an error page
87+
if file "$filename" | grep -q "ASCII text"; then
88+
echo "Got HTML error page, retrying..."
89+
rm -f "$filename"
90+
sleep 10
91+
attempt=$((attempt + 1))
92+
else
93+
echo "Successfully downloaded $filename"
94+
return 0
95+
fi
96+
else
97+
echo "Download failed, retrying..."
98+
sleep 10
99+
attempt=$((attempt + 1))
100+
fi
101+
done
102+
103+
echo "Failed to download $filename after $max_attempts attempts"
104+
return 1
105+
}
106+
107+
# Download key artifacts to validate with retries
108+
download_with_retry \
109+
"https://github.com/wallix/terraform-provider-wallix-bastion/releases/download/${TAG}/terraform-provider-wallix-bastion_${TAG}_linux_amd64.zip" \
110+
"terraform-provider-wallix-bastion_${TAG}_linux_amd64.zip"
80111
81-
echo "Downloading checksums..."
82-
curl -L -o "terraform-provider-wallix-bastion_${TAG}_SHA256SUMS" \
83-
"https://github.com/wallix/terraform-provider-wallix-bastion/releases/download/${TAG}/terraform-provider-wallix-bastion_${TAG}_SHA256SUMS"
112+
download_with_retry \
113+
"https://github.com/wallix/terraform-provider-wallix-bastion/releases/download/${TAG}/terraform-provider-wallix-bastion_${TAG}_windows_amd64.zip" \
114+
"terraform-provider-wallix-bastion_${TAG}_windows_amd64.zip"
115+
116+
download_with_retry \
117+
"https://github.com/wallix/terraform-provider-wallix-bastion/releases/download/${TAG}/terraform-provider-wallix-bastion_${TAG}_SHA256SUMS" \
118+
"terraform-provider-wallix-bastion_${TAG}_SHA256SUMS"
84119
85120
# Validate file types
86-
echo "\n=== Validating file types ==="
121+
echo ""
122+
echo "=== Validating file types ==="
87123
echo "Linux zip:"
88124
file "terraform-provider-wallix-bastion_${TAG}_linux_amd64.zip"
89125
90126
echo "Windows zip:"
91127
file "terraform-provider-wallix-bastion_${TAG}_windows_amd64.zip"
92128
93129
# Test extraction
94-
echo "\n=== Testing archive extraction ==="
130+
echo ""
131+
echo "=== Testing archive extraction ==="
95132
echo "Testing Linux zip extraction:"
96-
unzip -l "terraform-provider-wallix-bastion_${TAG}_linux_amd64.zip" | head -10
133+
if unzip -l "terraform-provider-wallix-bastion_${TAG}_linux_amd64.zip" | head -10; then
134+
echo "✓ Linux zip extraction successful"
135+
else
136+
echo "✗ Linux zip extraction failed"
137+
exit 1
138+
fi
97139
98140
echo "Testing Windows zip extraction:"
99-
unzip -l "terraform-provider-wallix-bastion_${TAG}_windows_amd64.zip" | head -10
141+
if unzip -l "terraform-provider-wallix-bastion_${TAG}_windows_amd64.zip" | head -10; then
142+
echo "✓ Windows zip extraction successful"
143+
else
144+
echo "✗ Windows zip extraction failed"
145+
exit 1
146+
fi
100147
101148
# Validate checksums exist
102-
echo "\n=== Validating checksums ==="
149+
echo ""
150+
echo "=== Validating checksums ==="
103151
if [ -f "terraform-provider-wallix-bastion_${TAG}_SHA256SUMS" ]; then
104152
echo "Checksums file found, checking format:"
105153
head -5 "terraform-provider-wallix-bastion_${TAG}_SHA256SUMS"
@@ -118,8 +166,10 @@ jobs:
118166
fi
119167
120168
# Verify one checksum
121-
echo "\n=== Verifying checksum ==="
169+
echo ""
170+
echo "=== Verifying checksum ==="
122171
sha256sum "terraform-provider-wallix-bastion_${TAG}_linux_amd64.zip"
123172
grep "terraform-provider-wallix-bastion_${TAG}_linux_amd64.zip" "terraform-provider-wallix-bastion_${TAG}_SHA256SUMS"
124173
125-
echo "\n=== Validation completed successfully! ==="
174+
echo ""
175+
echo "=== Validation completed successfully! ==="

0 commit comments

Comments
 (0)