Skip to content

Switch to Gitea incluster repository provider for e2e tests#27

Merged
creydr merged 19 commits intofunctions-dev:mainfrom
creydr:switch-to-gitea-incluster-git
Mar 16, 2026
Merged

Switch to Gitea incluster repository provider for e2e tests#27
creydr merged 19 commits intofunctions-dev:mainfrom
creydr:switch-to-gitea-incluster-git

Conversation

@creydr
Copy link
Collaborator

@creydr creydr commented Mar 16, 2026

Using Gitea as a Git repository provider for e2e tests to remove dependency to presetup Git repositories on Github

creydr added 15 commits March 16, 2026 13:21
- Configure Gitea with NodePort on ports 30000 (HTTP) and 30022 (SSH)
- Set admin credentials for test usage
- Create ConfigMap with Gitea endpoint for test discovery
- Disable persistence for ephemeral test environment
- Implement NewGiteaClient() that discovers Gitea endpoint from ConfigMap
- Create Gitea SDK client with admin authentication
- Add Gitea SDK dependency to go.mod
- Define RepositoryProvider interface for git server operations
- Allows switching between Gitea/GitHub/GitLab without test code changes
- GiteaClient will implement this interface
- Implement CreateUser() for creating users with specific credentials
- Implement DeleteUser() for cleanup
- Implement CreateRandomUser() for test isolation
- GiteaClient now partially implements RepositoryProvider interface
- Implement CreateRepo() for creating repositories
- Implement DeleteRepo() for cleanup
- Implement CreateRandomRepo() for test isolation
- Build and return repository URLs automatically
- Implement CreateAccessToken() for generating user tokens
- Support authentication for private repositories
- GiteaClient now fully implements RepositoryProvider interface
- Add buildAuthURL() for embedding credentials in git URLs
- Add InitializeRepoWithFunction() for setting up function repos
- Add CommitAndPush() for flexible commit/push with proper error handling
- Helpers simplify test code and promote reusability
- Add repoProvider variable using RepositoryProvider interface
- Initialize with GiteaClient in BeforeSuite
- Verify provider is not nil before tests run
- Interface allows easy switching to other providers
- Replace GitHub cloning with RepositoryProvider workflow in BeforeEach
- Use InitializeRepoWithFunction() helper for repo setup
- Update Function specs to use repository provider URLs
- Add proper cleanup of repository resources in AfterEach
- Tests now isolated and independent of external GitHub
- Keep abstraction by using generic terminology
- Update RepositoryProvider interface to return cleanup functions
- Implement cleanup functions in CreateUser, CreateRepo, etc.
- Use Ginkgo's DeferCleanup for automatic cleanup in tests
- Simplify AfterEach blocks to only handle failure logging
- Much cleaner and less error-prone test code
- Update helper functions to accept and use repoURL parameter
- Replace GitHub URLs with RepositoryProvider workflow in setup functions
- Track repoURLs alongside namespaces for all tests
- Use DeferCleanup for automatic resource cleanup
- Tests now use in-cluster repository provider for all git operations
- Remove unused rand import
- Define TestNamespace struct with Name and RepoURL fields
- Replace separate namespace and repoURL slices with single slice
- Update all functions to accept/return TestNamespace
- Prevents misalignment of parallel slices
- Much safer and cleaner API
- Comprehensive guide for using RepositoryProvider in tests
- Document test patterns and helper methods
- Explain DeferCleanup pattern for automatic cleanup
- Add troubleshooting section
- Describe implementation details and architecture
- Update README with Gitea test information
Fixes multiple issues preventing e2e tests from running with in-cluster
Gitea instead of external GitHub:

- Set MustChangePassword to false when creating users to prevent auth errors
- Use AdminCreateRepo to create repos under correct user account
- Rewrite function initialization to avoid git/func init conflicts
- Add git user configuration for commits
- Use main branch instead of master for modern git compatibility
- Improve error messages by using utils.Run for all git commands
- Add function code to "not yet deployed" test scenario
@creydr creydr enabled auto-merge (squash) March 16, 2026 12:25
@creydr creydr disabled auto-merge March 16, 2026 12:25
@creydr creydr enabled auto-merge (squash) March 16, 2026 12:26
creydr added 4 commits March 16, 2026 13:30
In CI environments, git may not have a default branch name configured,
causing 'git init' to create a branch with a different name (e.g., master).
This causes the subsequent 'git push -u origin main' to fail with
'src refspec main does not match any'.

Use 'git init -b main' to explicitly create the main branch, ensuring
consistent behavior across all environments.
@creydr creydr merged commit 5d2bec3 into functions-dev:main Mar 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant