Skip to content

Commit 8a77a63

Browse files
committed
chore: test determinism
1 parent 483a5fb commit 8a77a63

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Validate Determinism
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
validate-determinism:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Install Speakeasy
16+
uses: mheap/setup-go-cli@fa9b01cdd4115eac636164f0de43bf7d51c82697 # v1
17+
with:
18+
owner: speakeasy-api
19+
repo: speakeasy
20+
cli_name: speakeasy
21+
package_type: zip
22+
23+
- name: Configure speakeasy CLI
24+
run: |
25+
mkdir -p ~/.speakeasy
26+
echo 'speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}' > ~/.speakeasy/config.yaml
27+
28+
- name: Checkout current repo
29+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
30+
with:
31+
ref: ${{ github.ref }}
32+
33+
- name: Log initial git status
34+
run: |
35+
echo "Initial git status:"
36+
git status
37+
38+
- name: Run Speakeasy with frozen workflow lockfile
39+
run: speakeasy run --frozen-workflow-lockfile
40+
41+
- name: Check for changes
42+
id: check_changes
43+
run: |
44+
echo "Git status after speakeasy run:"
45+
git status
46+
47+
if [ -n "$(git status --porcelain)" ]; then
48+
echo "changes_detected=true" >> $GITHUB_OUTPUT
49+
echo "Non-deterministic changes detected!"
50+
else
51+
echo "changes_detected=false" >> $GITHUB_OUTPUT
52+
echo "No changes detected - workflow is deterministic"
53+
fi
54+
55+
- name: Create branch and push changes if non-deterministic
56+
if: steps.check_changes.outputs.changes_detected == 'true'
57+
run: |
58+
# Extract branch name from ref
59+
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
60+
NON_DETERMINISM_BRANCH="speakeasy-nondeterminism/${BRANCH_NAME}"
61+
62+
echo "Creating branch: $NON_DETERMINISM_BRANCH"
63+
64+
# Configure git
65+
git config user.name "github-actions[bot]"
66+
git config user.email "github-actions[bot]@users.noreply.github.com"
67+
68+
# Create and checkout new branch
69+
git checkout -b "$NON_DETERMINISM_BRANCH"
70+
71+
# Stage all changes
72+
git add -A
73+
74+
# Show what we're committing
75+
echo "Changes to be committed:"
76+
git status
77+
78+
# Commit changes
79+
git commit -m "Non-deterministic changes detected from branch ${BRANCH_NAME}"
80+
81+
# Push to remote
82+
git push origin "$NON_DETERMINISM_BRANCH" --force
83+
84+
- name: Fail workflow if changes detected
85+
if: steps.check_changes.outputs.changes_detected == 'true'
86+
run: |
87+
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
88+
NON_DETERMINISM_BRANCH="speakeasy-nondeterminism/${BRANCH_NAME}"
89+
echo "::error::Non-deterministic changes detected! Changes have been pushed to branch: $NON_DETERMINISM_BRANCH"
90+
exit 1

.speakeasy/workflow.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sources:
55
inputs:
66
- location: https://spec.speakeasy.com/speakeasy-self/speakeasy-self/speakeasy-api
77
registry:
8-
location: registry.speakeasyapi.dev/speakeasy-self/speakeasy-self/ts-client-source
8+
location: registry.speakeasyapi.dev/speakeasy-self/speakeasy-self/my-source
99
targets:
1010
speakeasy-client-sdk-typescript:
1111
target: typescript

0 commit comments

Comments
 (0)