Skip to content

Commit c5bb568

Browse files
committed
Simplify dispatch workflow to e2e science workflow
Replace generic repository dispatch handler with simplified e2e science workflow that only handles build, e2e tests, and push operations based on client payload parameters. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
1 parent e97681d commit c5bb568

File tree

1 file changed

+31
-167
lines changed

1 file changed

+31
-167
lines changed

.github/workflows/dispatch.yaml

Lines changed: 31 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -1,173 +1,37 @@
1-
name: Generic Repository Dispatch Handler
1+
name: "e2e: platform=k8s, survey=ztf, science=true, infra=self-hosted"
22

33
on:
44
repository_dispatch:
5-
types:
6-
- test-dispatch
7-
- test-dispatch-with-artifacts
8-
- build-and-test
9-
- deploy-test
10-
- custom-action
11-
12-
env:
13-
# Default values that can be overridden by client payload
14-
DEFAULT_GO_VERSION: '1.21'
15-
DEFAULT_NODE_VERSION: '20'
16-
DEFAULT_PYTHON_VERSION: '3.11'
5+
types: [e2e-science]
176

187
jobs:
19-
dispatch-handler:
20-
runs-on: ${{ github.event.client_payload.runner || 'ubuntu-latest' }}
21-
8+
e2e-science:
9+
runs-on: ubuntu-latest
2210
steps:
23-
- name: Checkout code
24-
uses: actions/checkout@v4
25-
with:
26-
ref: ${{ github.event.client_payload.ref || github.ref }}
27-
28-
- name: Display dispatch event information
29-
run: |
30-
echo "Repository dispatch received!"
31-
echo "Event type: ${{ github.event.action }}"
32-
echo "Repository: ${{ github.repository }}"
33-
echo "Ref: ${{ github.event.client_payload.ref || github.ref }}"
34-
echo "Client payload: ${{ toJson(github.event.client_payload) }}"
35-
36-
- name: Setup environment variables
37-
run: |
38-
# Set environment variables from client payload with defaults
39-
echo "PROJECT_NAME=${{ github.event.client_payload.project_name || github.event.repository.name }}" >> $GITHUB_ENV
40-
echo "BUILD_TYPE=${{ github.event.client_payload.build_type || 'test' }}" >> $GITHUB_ENV
41-
echo "ENVIRONMENT=${{ github.event.client_payload.environment || 'development' }}" >> $GITHUB_ENV
42-
43-
- name: Setup Go (if requested)
44-
if: github.event.client_payload.setup_go == 'true' || github.event.client_payload.languages.go == 'true'
45-
uses: actions/setup-go@v4
46-
with:
47-
go-version: ${{ github.event.client_payload.go_version || env.DEFAULT_GO_VERSION }}
48-
49-
- name: Setup Node.js (if requested)
50-
if: github.event.client_payload.setup_node == 'true' || github.event.client_payload.languages.node == 'true'
51-
uses: actions/setup-node@v4
52-
with:
53-
node-version: ${{ github.event.client_payload.node_version || env.DEFAULT_NODE_VERSION }}
54-
55-
- name: Setup Python (if requested)
56-
if: github.event.client_payload.setup_python == 'true' || github.event.client_payload.languages.python == 'true'
57-
uses: actions/setup-python@v4
58-
with:
59-
python-version: ${{ github.event.client_payload.python_version || env.DEFAULT_PYTHON_VERSION }}
60-
61-
- name: Display artifacts information
62-
if: github.event.client_payload.artifacts
63-
run: |
64-
echo "Artifacts received:"
65-
echo "${{ toJson(github.event.client_payload.artifacts) }}"
66-
67-
- name: Extract and process artifacts
68-
if: github.event.client_payload.artifacts
69-
run: |
70-
mkdir -p artifacts
71-
72-
# Extract all artifact types dynamically
73-
if echo '${{ toJson(github.event.client_payload.artifacts) }}' | jq -e 'to_entries[]' > /dev/null; then
74-
for artifact in $(echo '${{ toJson(github.event.client_payload.artifacts) }}' | jq -r 'to_entries[] | "\(.key):\(.value.type):\(.value.content)"'); do
75-
filename=$(echo $artifact | cut -d: -f1)
76-
type=$(echo $artifact | cut -d: -f2)
77-
content=$(echo $artifact | cut -d: -f3-)
78-
79-
echo "Processing artifact: $filename (type: $type)"
80-
81-
# Handle different content encodings
82-
if echo "$content" | base64 -d > /dev/null 2>&1; then
83-
echo "$content" | base64 -d > "artifacts/$filename"
84-
else
85-
echo "$content" > "artifacts/$filename"
86-
fi
87-
88-
echo "Extracted: $filename"
89-
done
90-
fi
91-
92-
# Save metadata if present
93-
if echo '${{ toJson(github.event.client_payload.artifacts) }}' | jq -e '.metadata' > /dev/null; then
94-
echo '${{ toJson(github.event.client_payload.artifacts.metadata) }}' > artifacts/metadata.json
95-
echo "Extracted: metadata.json"
96-
fi
97-
98-
ls -la artifacts/ || echo "No artifacts directory created"
99-
100-
- name: Set artifact name
101-
if: github.event.client_payload.artifacts
102-
run: |
103-
# Use provided name or generate default based on project and timestamp
104-
ARTIFACT_NAME="${{ github.event.client_payload.artifact_name }}"
105-
if [ -z "$ARTIFACT_NAME" ]; then
106-
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
107-
ARTIFACT_NAME="${{ env.PROJECT_NAME }}-${{ github.event.action }}-${TIMESTAMP}"
108-
fi
109-
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
110-
echo "Artifact name will be: ${ARTIFACT_NAME}"
111-
112-
- name: Upload artifacts to GitHub Actions
113-
if: github.event.client_payload.artifacts
114-
uses: actions/upload-artifact@v4
115-
with:
116-
name: ${{ env.ARTIFACT_NAME }}
117-
path: artifacts/
118-
119-
- name: Execute custom commands
120-
if: github.event.client_payload.commands
121-
run: |
122-
echo "Executing custom commands..."
123-
echo '${{ github.event.client_payload.commands }}' | base64 -d | bash
124-
125-
- name: Run default action based on dispatch type
126-
run: |
127-
case "${{ github.event.action }}" in
128-
"test-dispatch")
129-
echo "Running basic test dispatch for ${{ env.PROJECT_NAME }}"
130-
echo "Environment: ${{ env.ENVIRONMENT }}"
131-
;;
132-
"build-and-test")
133-
echo "Running build and test workflow for ${{ env.PROJECT_NAME }}"
134-
if [ -f "Makefile" ]; then
135-
make test || echo "Make test not available"
136-
elif [ -f "package.json" ]; then
137-
npm test || echo "NPM test not available"
138-
elif [ -f "go.mod" ]; then
139-
go test ./... || echo "Go test not available"
140-
else
141-
echo "No recognized build system found"
142-
fi
143-
;;
144-
"deploy-test")
145-
echo "Running deployment test for ${{ env.PROJECT_NAME }}"
146-
echo "Target environment: ${{ env.ENVIRONMENT }}"
147-
;;
148-
"custom-action")
149-
echo "Custom action triggered for ${{ env.PROJECT_NAME }}"
150-
echo "Additional logic can be added here"
151-
;;
152-
*)
153-
echo "Unknown dispatch type: ${{ github.event.action }}"
154-
echo "Available types: test-dispatch, build-and-test, deploy-test, custom-action"
155-
;;
156-
esac
157-
158-
- name: Display environment info
159-
run: |
160-
echo "=== Environment Information ==="
161-
echo "Project: ${{ env.PROJECT_NAME }}"
162-
echo "Build Type: ${{ env.BUILD_TYPE }}"
163-
echo "Environment: ${{ env.ENVIRONMENT }}"
164-
echo "Runner: ${{ runner.os }}"
165-
if command -v go &> /dev/null; then
166-
echo "Go version: $(go version)"
167-
fi
168-
if command -v node &> /dev/null; then
169-
echo "Node version: $(node --version)"
170-
fi
171-
if command -v python3 &> /dev/null; then
172-
echo "Python version: $(python3 --version)"
173-
fi
11+
- name: build
12+
run: |
13+
image="${{ github.event.client_payload.image }}"
14+
if [ "${{ github.event.client_payload.build }}" == "true" ]; then
15+
echo "build success for image $image"
16+
else
17+
echo "build failed for image $image"
18+
exit 1
19+
fi
20+
- name: e2e
21+
run: |
22+
cluster="${{ github.event.client_payload.cluster }}"
23+
if [ "${{ github.event.client_payload.e2e }}" == "true" ]; then
24+
echo "Succeed to run e2e tests on cluster $cluster"
25+
else
26+
echo "Failed to run e2e tests on cluster $cluster"
27+
exit 1
28+
fi
29+
- name: push
30+
run: |
31+
image="${{ github.event.client_payload.image }}"
32+
if [ "${{ github.event.client_payload.push }}" == "true" ]; then
33+
echo "Succeed in pushing image $image"
34+
else
35+
echo "Failed to push image $image"
36+
exit 1
37+
fi

0 commit comments

Comments
 (0)