Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Test writing remote Actions locally #2155

Merged
merged 4 commits into from
Feb 23, 2024

Conversation

ChristopherHX
Copy link
Contributor

@ChristopherHX ChristopherHX commented Jan 18, 2024

How to test

Usage: ./act --local-repository "https://github.com/test/test@v0=$PWD" -W test.yml -P self-hosted=-self-hosted -v

Now also possible ./act --local-repository "test/test@v0=$PWD" -W test.yml -P self-hosted=-self-hosted -v

on: push
jobs:
  _:
    runs-on: self-hosted
    steps:
    - uses: test/test@v0

action.yml in cwd

runs:
  using: composite
  steps:
  - run: echo Test

Why?

Local actions cannot have pre steps and use a different syntax in the uses key

Copy link
Contributor

github-actions bot commented Jan 18, 2024

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ EDITORCONFIG editorconfig-checker 4 0 0.02s
✅ REPOSITORY gitleaks yes no 2.34s
✅ REPOSITORY git_diff yes no 0.18s
✅ REPOSITORY grype yes no 7.87s
✅ REPOSITORY secretlint yes no 1.16s
✅ REPOSITORY trivy-sbom yes no 0.61s
✅ REPOSITORY trufflehog yes no 6.98s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

Copy link

@ethanwater ethanwater left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey, you should probably squash any related commits. quality of life improvement so the devs don't have to navigate much.

@ChristopherHX
Copy link
Contributor Author

Actually only two commits here are implementation for this pr.

The rest is part of #1954, that's why I initially didn't create a pr for this.

Copy link

codecov bot commented Jan 20, 2024

Codecov Report

Attention: Patch coverage is 68.85246% with 19 lines in your changes are missing coverage. Please review.

Project coverage is 61.99%. Comparing base (5a80a04) to head (5c1546f).
Report is 16 commits behind head on master.

Files Patch % Lines
pkg/runner/local_repository_cache.go 68.85% 14 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2155      +/-   ##
==========================================
+ Coverage   61.56%   61.99%   +0.43%     
==========================================
  Files          53       56       +3     
  Lines        9002     9139     +137     
==========================================
+ Hits         5542     5666     +124     
- Misses       3020     3026       +6     
- Partials      440      447       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ChristopherHX ChristopherHX changed the base branch from master to refactor-filecollector-into-new-package January 29, 2024 14:27
Base automatically changed from refactor-filecollector-into-new-package to master January 30, 2024 00:46
@ChristopherHX ChristopherHX marked this pull request as ready for review January 30, 2024 15:13
@ChristopherHX ChristopherHX requested a review from a team as a code owner January 30, 2024 15:13
Comment on lines +1 to +3
local-repositories:
https://github.com/nektos/test-override@a: testdata/actions/node20
nektos/test-override@b: testdata/actions/node16
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a new config.yml for tests, to configure selected config options

Comment on lines +29 to +34
if purl, err := goURL.Parse(url); err == nil {
if dest, ok := l.LocalRepositories[fmt.Sprintf("%s@%s", strings.TrimPrefix(purl.Path, "/"), ref)]; ok {
l.CacheDirCache[fmt.Sprintf("%s@%s", cacheDir, ref)] = dest
return ref, nil
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

short localrepository definition without uri host are now matchng


func (l *LocalRepositoryCache) Fetch(ctx context.Context, cacheDir, url, ref, token string) (string, error) {
if dest, ok := l.LocalRepositories[fmt.Sprintf("%s@%s", url, ref)]; ok {
l.CacheDirCache[fmt.Sprintf("%s@%s", cacheDir, ref)] = dest
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CacheDirCache no longer causes key collision if you override the same action with different version

@mergify mergify bot merged commit ac6a465 into master Feb 23, 2024
10 checks passed
jmikedupont2 pushed a commit to meta-introspector/act that referenced this pull request Mar 10, 2024
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants