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

run-vcpkg@v11 requires manually setting environment variables for caching to work #195

Closed
akrieger opened this issue Apr 4, 2023 · 6 comments

Comments

@akrieger
Copy link

akrieger commented Apr 4, 2023

Using vcpkg in manifest mode, our workflow which worked on v10 emits this output and doesn't cache.

         "D:\a\Cataclysm-DDA\b\vcpkg\vcpkg.exe" install "--host-triplet=x64-windows-static" --x-wait-for-lock --triplet "x64-windows-static" --vcpkg-root "D:\a\Cataclysm-DDA\b\vcpkg\\" "--x-manifest-root=D:\a\Cataclysm-DDA\Cataclysm-DDA\msvc-full-features\\" "--x-install-root=D:\a\Cataclysm-DDA\Cataclysm-DDA\msvc-full-features\vcpkg_installed\x64-windows-static\\" --clean-after-build
         "D:\a\Cataclysm-DDA\b\vcpkg\vcpkg.exe" install "--host-triplet=x64-windows-static" --x-wait-for-lock --triplet "x64-windows-static" --vcpkg-root "D:\a\Cataclysm-DDA\b\vcpkg\\" "--x-manifest-root=D:\a\Cataclysm-DDA\Cataclysm-DDA\msvc-full-features\\" "--x-install-root=D:\a\Cataclysm-DDA\Cataclysm-DDA\msvc-full-features\vcpkg_installed\x64-windows-static\\" --clean-after-build
     3>D:\a\Cataclysm-DDA\b\vcpkg\scripts\buildsystems\msbuild\vcpkg.targets(183,5): warning : warning: Embedding `vcpkg-configuration` in a manifest file is an EXPERIMENTAL feature. [D:\a\Cataclysm-DDA\Cataclysm-DDA\msvc-full-features\Cataclysm-lib-vcpkg-static.vcxproj]
         The GHA binary source requires the ACTIONS_RUNTIME_TOKEN and ACTIONS_CACHE_URL environment variables to be set. See https://learn.microsoft.com/en-us/vcpkg/users/binarycaching#gha for details.
     3>D:\a\Cataclysm-DDA\b\vcpkg\scripts\buildsystems\msbuild\vcpkg.targets(183,5): error MSB3073: The command ""D:\a\Cataclysm-DDA\b\vcpkg\vcpkg.exe" install "--host-triplet=x64-windows-static" --x-wait-for-lock --triplet "x64-windows-static" --vcpkg-root "D:\a\Cataclysm-DDA\b\vcpkg\\" "--x-manifest-root=D:\a\Cataclysm-DDA\Cataclysm-DDA\msvc-full-features\\" "--x-install-root=D:\a\Cataclysm-DDA\Cataclysm-DDA\msvc-full-features\vcpkg_installed\x64-windows-static\\" --clean-after-build" exited with code 1. [D:\a\Cataclysm-DDA\Cataclysm-DDA\msvc-full-features\Cataclysm-lib-vcpkg-static.vcxproj]
@akrieger akrieger changed the title run-vcpkg@11 seemingly fails with missing environment variables run-vcpkg@v11 seemingly fails with missing environment variables Apr 4, 2023
@lukka
Copy link
Owner

lukka commented Apr 4, 2023

@akrieger good question, I need to add explicitly this info to the run-vcpkg@v11 documentation.
I imagine you have a workflow that does this:

     uses: run-vcpkg@v11. # <= Succeeds
     run: vcpkg.exe install <rest of cmd line> # <= Fails with missing env var error

When running vcpkg yourself (i.e. when it is not run by the action), you need to add the following variables, like it is done in the C++ project template:

      - uses: actions/github-script@v6
        with:
          script: |
            core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
            core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');

I see two fixes here:

  • run-vcpkg@v11 must define those two variables, so the user does not need to do it manually. Note that in the workflow linked above the run-vcpkg action is not used at all, hence the definition of the env var must be done explicitly in the workflow.
  • add docs to run-vcpkg@v11 about these variables.

@akrieger
Copy link
Author

akrieger commented Apr 4, 2023

Our workflow file uses run-vcpkg and then manually invokes vcpkg via manifest mode. I will test with setting the env vars manually like you showed.

    - name: Restore artifacts, or run vcpkg, build and cache artifacts
      uses: lukka/run-vcpkg@v11
      id: runvcpkg
      with:
        # run-vcpkg tries to hash vcpkg.json but complans if it finds more than one.
        # That said, we also have our custom vcpkg_triplets to hash, so we keep everything the same.
        appendedCacheKey: ${{ hashFiles( 'msvc-full-features/vcpkg.json', 'msvc-object_creator/vcpkg.json', '.github/vcpkg_triplets/**', '.github/vckg_ports/**' ) }}
        # Rev this value to drop cache without changing vcpkg commit
        prependedCacheKey: v1-x64-full
        vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg'
        # Caching happens as a post-action which runs at the end of the whole workflow
        vcpkgGitCommitId: '5b1214315250939257ef5d62ecdcbca18cf4fb1c'

    - name: Integrate vcpkg
      run: |
        vcpkg integrate install --vcpkg-root '${{ runner.workspace }}\b\vcpkg'
        
        ...
        
    - name: Build <-- vcokg invoked by msbuild here
      run: |
          msbuild -m -p:Configuration=Release -p:Platform=x64 "-target:Cataclysm-vcpkg-static;Cataclysm-test-vcpkg-static;JsonFormatter-vcpkg-static" msvc-full-features/Cataclysm-vcpkg-static.sln
          msbuild -m -p:Configuration=Release -p:Platform=x64 "-target:ObjectCreator-vcpkg-static" msvc-object_creator/ObjectCreator-vcpkg-static.sln

@akrieger
Copy link
Author

akrieger commented Apr 4, 2023

Setting the env vars seemed to suppress that output. I found the job failing is caused by a changed portfile, so I'll edit the issue title appropriately.

@akrieger akrieger changed the title run-vcpkg@v11 seemingly fails with missing environment variables run-vcpkg@v11 requires manually setting environment variables for caching to work Apr 4, 2023
@lukka
Copy link
Owner

lukka commented Apr 5, 2023

@akrieger fixed with release https://github.com/lukka/run-vcpkg/releases/tag/v11.1, let me know!

@akrieger
Copy link
Author

akrieger commented Apr 5, 2023

     Attempting to fetch 19 package(s) from GHA
     ...
     Restored 19 package(s) from GHA in 9.5 s. Use --debug to see more details.

Seems like it worked! I removed the logic which set the env vars myself, vcpkg seemed to restore from its own cache correctly.

@lukka
Copy link
Owner

lukka commented Apr 6, 2023

@akrieger let me know if anything else needs to be fixed, thanks!

@lukka lukka closed this as completed Apr 6, 2023
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

No branches or pull requests

2 participants