Skip to content

Conversation

@ekampf
Copy link
Collaborator

@ekampf ekampf commented Dec 19, 2025

Resolves #48

Changes

Cache the .deb file on linux install

Timing before change (see this run):

  • ubuntu-latest - 25s
  • ubuntu-2404 - 21s
  • ubuntu-2204 - 22s

Timing After change (see this run):

  • ubuntu-latest - 14s
  • ubuntu-2404 - 14s
  • ubuntu-2204 - 15s

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an optional caching mechanism for Twingate .deb packages on Linux to improve installation speed. The change introduces a new cache input parameter (defaulting to true) that allows users to cache downloaded .deb packages across workflow runs, reducing installation time by approximately 40-50% (from ~22s to ~14s).

Key Changes

  • Added a new cache input parameter to enable/disable package caching
  • Split the Linux installation into three steps: cache retrieval, package download (on cache miss), and installation from cache
  • Retained the original installation method as a fallback when caching is disabled

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

action.yml Outdated
id: cache-twingate
with:
path: /tmp/twingate-cache
key: twingate-deb-${{ runner.os }}-${{ runner.arch }}
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

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

The cache key does not include the package version, which means that when a new version of the Twingate package is released, the cached old version will continue to be used indefinitely. Consider including a version identifier or timestamp in the cache key, or add a mechanism to invalidate the cache periodically (e.g., using a date-based key component like twingate-deb-${{ runner.os }}-${{ runner.arch }}-v1 where v1 can be manually incremented when needed).

Suggested change
key: twingate-deb-${{ runner.os }}-${{ runner.arch }}
key: twingate-deb-${{ runner.os }}-${{ runner.arch }}-v1

Copilot uses AI. Check for mistakes.
echo "deb [trusted=yes] https://packages.twingate.com/apt/ /" | sudo tee /etc/apt/sources.list.d/twingate.list
sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/twingate.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
cd /tmp/twingate-cache
apt-get download twingate
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

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

The 'apt-get download' command is missing 'sudo' prefix. Without elevated privileges, this command will fail to download the package. This should be 'sudo apt-get download twingate' to match the pattern used elsewhere in the action.

Suggested change
apt-get download twingate
sudo apt-get download twingate

Copilot uses AI. Check for mistakes.
if: runner.os == 'Linux' && inputs.cache == 'true'
shell: bash
run: |
sudo dpkg -i /tmp/twingate-cache/twingate*.deb || true
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

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

The dpkg installation step uses '|| true' to suppress errors, which could mask legitimate installation failures. If the .deb file doesn't exist or is corrupted, this would silently continue and only rely on 'apt-get install -f' to fix issues. Consider adding explicit error checking to verify the .deb file exists before attempting installation, or at least check that the subsequent apt-get command succeeds.

Suggested change
sudo dpkg -i /tmp/twingate-cache/twingate*.deb || true
set -e
if ! ls /tmp/twingate-cache/twingate*.deb >/dev/null 2>&1; then
echo "Error: No Twingate .deb package found in /tmp/twingate-cache" >&2
exit 1
fi
sudo dpkg -i /tmp/twingate-cache/twingate*.deb

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

This pull request is stale because it has been open 5 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the wontfix This will not be worked on label Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Is there a reliable way to cache twingate?

2 participants