Skip to content

Commit

Permalink
✨ Add support for Ubuntu 22.04 based github runners (#220)
Browse files Browse the repository at this point in the history
As there is no support yet for AppImage on Ubuntu 22.04, see
#206 (comment)
and GitHub rolls out Ubuntu 22.04 soon, see
actions/runner-images#6399

Newer tectonic version doesnt seem to be need any dependencies on linux
anymore, according to the latest install-docs
https://tectonic-typesetting.github.io/book/latest/installation/

This means we can use the normal .tar.gz file on these versions. Stick
to AppImage on older versions (<= 0.10.0) to keep compatibility high.
  • Loading branch information
WtfJoke authored Dec 11, 2022
2 parents 60efc9e + 1135dc0 commit e61d40c
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 57 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ jobs:
test: # make sure the action works on a clean machine without building
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
os: [windows-latest, ubuntu-latest, macos-latest, ubuntu-22.04]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: ./
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
tectonic-version: 0.4.0
biber-version: 2.15
tectonic-version: 0.12.0
biber-version: 2.16
- name: Tectonic version
run: tectonic --version
- name: Biber version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- run: |
yarn install
- run: |
yarn run build && yarn run package
yarn run update-dist
- name: Did dist folder changed?
run: |
EXIT_CODE=0
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16
98 changes: 55 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,51 @@ The `wtfjoke/setup-tectonic` action is a JavaScript action that sets up [Tectoni
- Downloading a requested version of Tectonic and adding it to the `PATH`.
- (Optionally) downloading a requested version of [Biber](https://sourceforge.net/projects/biblatex-biber/) and adding it to the `PATH`.

# :wrench: Usage
# 🔧 Usage

This action can be run on `ubuntu-latest`, `windows-latest`, and `macos-latest` GitHub Actions runners.

The default configuration installs the latest version of Tectonic. The `GITHUB_TOKEN` is needed to query the Github Releases of `tectonic-typesetting/tectonic` to download tectonic.

You can even use caching (see example below) to speed up your workflow :tada:.
You can even use caching (see example below) to speed up your workflow 🎉.

See [action.yml](https://github.com/WtfJoke/setup-tectonic/blob/main/action.yml) for a full description of all parameters.

```yml
steps:
- uses: wtfjoke/setup-tectonic@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- run: tectonic main.tex
- uses: wtfjoke/setup-tectonic@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- run: tectonic main.tex
```
You can also download a specific version of Tectonic
```yml
steps:
- uses: wtfjoke/setup-tectonic@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
tectonic-version: 0.7.1
- run: tectonic main.tex
- uses: wtfjoke/setup-tectonic@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
tectonic-version: 0.12.0
- run: tectonic main.tex
```
If you want to use biber, specify a biber version (for a full example see [below](https://github.com/WtfJoke/setup-tectonic#with-biber))
```yml
steps:
- uses: wtfjoke/setup-tectonic@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
biber-version: 2.15
- run: biber --version
- uses: wtfjoke/setup-tectonic@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
biber-version: 2.16
- run: biber --version
```
## Upload pdf (using `actions/upload-artifact`)

```yml
name: 'Build LaTex Document'
on:
on:
push:
jobs:
build:
Expand All @@ -73,9 +77,10 @@ jobs:
```

## With enabled cache (using `actions/cache`)

```yml
name: 'Build LaTex Document'
on:
on:
push:
jobs:
build:
Expand All @@ -90,7 +95,7 @@ jobs:
path: ~/.cache/Tectonic
key: ${{ runner.os }}-tectonic-${{ hashFiles('**/*.tex') }}
restore-keys: |
${{ runner.os }}-tectonic-
${{ runner.os }}-tectonic-
- uses: wtfjoke/setup-tectonic@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -104,9 +109,10 @@ jobs:
```

## With biber

```yml
name: 'Build LaTex Document with Biber'
on:
on:
push:
jobs:
build:
Expand All @@ -121,11 +127,11 @@ jobs:
path: ~/.cache/Tectonic
key: ${{ runner.os }}-tectonic-${{ hashFiles('**/*.tex') }}
restore-keys: |
${{ runner.os }}-tectonic-
${{ runner.os }}-tectonic-
- uses: wtfjoke/setup-tectonic@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
biber-version: "latest"
biber-version: 'latest'
- name: Run Tectonic + Biber
run: tectonic main.tex
- name: Upload pdf
Expand All @@ -136,6 +142,7 @@ jobs:
```

**Note**: Tectonic has added biber support in `0.7.1` (see [changelog](https://github.com/tectonic-typesetting/tectonic/releases/tag/tectonic%400.7.1)). Prior to that version you need to run following commands:

```yml
run: |
tectonic --keep-intermediates --reruns 0 main.tex
Expand All @@ -145,53 +152,58 @@ run: |

# 📊 Comparison to other LaTeX/Tectonic actions like [vinay0410/tectonic-action](https://github.com/vinay0410/tectonic-action)

| Pro | Description |
| --------------------------|:--------------------------------------------------------------------------------------------|
| :zap: Performance | - Supports caching </br> - Native Javascript Action's are faster than docker (:whale:) based actions |
| :robot: Future proofed | New tectonic versions right on release without code changes |
| :art: Customizability | Do one thing and do it well - let other actions do what they can do best |
| Pro | Description |
| ---------------------- | :--------------------------------------------------------------------------------------------------- |
| :zap: Performance | - Supports caching </br> - Native Javascript Action's are faster than docker (:whale:) based actions |
| :robot: Future proofed | New tectonic versions right on release without code changes |
| :art: Customizability | Do one thing and do it well - let other actions do what they can do best |

</br>

## Explanation

This action was created because all existing Github Actions for compiling LaTeX documents I came across are docker based actions, which are [slower than Javascript based actions](https://docs.github.com/en/actions/creating-actions/about-actions#docker-container-actions).

LaTex Docker images tend to be huge (2gb+). Tectonic images are an exception but they need to be maintained and updated with new Tectonic versions. This is not often the case, at the time of writing [my docker image](https://github.com/WtfJoke/tectonic-docker) is the only one up to date with the latest tectonic version.

In comparsion, this github action doesnt need an update if a new release of tectonic is released, it just works.
In comparison, this github action doesn't need an update if a new release of tectonic is released, it just works.

The existing github actions doesnt support biber (notable exception: [birjolaxew/tectonic-biber-action](https://github.com/birjolaxew/tectonic-biber-action)).
The existing github actions doesn't support biber (notable exception: [birjolaxew/tectonic-biber-action](https://github.com/birjolaxew/tectonic-biber-action)).

Additionaly most of the github actions tend to do too much or are too strict.
Additionally most of the github actions tend to do too much or are too strict.

This github action has one job, to setup tectonic (and optionally biber). You can choose on your own how you want to call tectonic, how and if you want to cache your dependencies, how and if you want to upload your pdf. Depending on your decisions you can choose the best action to do the corresponding job (eg. [actions/cache](https://github.com/actions/cache) for caching, [actions/upload-artifact](https://github.com/actions/upload-artifact) or [actions/create-release](https://github.com/actions/create-release) for publishing your pdf)


# 🤓 How does the cache works?

The official cache action [actions/cache](https://github.com/actions/cache) has three parameters:
- `path` - A list of files, directories, and wildcard patterns to cache and restore.
- `key` - Primary cache key - If the key has a cache-hit, it means the cache is up to date. The execution of a tool shouldnt change the cache anymore.
- `restore-keys` - If there is no key hit with `key` - These will be used to restore the cache. The execution of a tool most likely will change the cache.


- `path` - A list of files, directories, and wildcard patterns to cache and restore.
- `key` - Primary cache key - If the key has a cache-hit, it means the cache is up to date. The execution of a tool should'nt change the cache anymore.
- `restore-keys` - If there is no key hit with `key` - These will be used to restore the cache. The execution of a tool most likely will change the cache.

## Path

For tectonic the cache directories (`path`) are as follows (see also [tectonic-typesetting/tectonic#159](https://github.com/tectonic-typesetting/tectonic/issues/159)):

| OS | Cache-Directory | Run-Command to export it as environment variable
| ----------- | ----------------------------- | --------------------------------------------|
| Linux | `~/.cache/Tectonic` | `echo TECTONIC_CACHE_PATH=~/.cache/Tectonic >> $GITHUB_ENV`
| Mac | `~/Library/Caches/Tectonic` | `echo TECTONIC_CACHE_PATH=~/Library/Caches/Tectonic >> $GITHUB_ENV`
| Windows | `%LOCALAPPDATA%\TectonicProject\Tectonic` | <code>echo TECTONIC_CACHE_PATH=$env:LOCALAPPDATA\TectonicProject\Tectonic | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append`</code>
| OS | Cache-Directory | Run-Command to export it as environment variable |
| ------- | ----------------------------------------- | ------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| Linux | `~/.cache/Tectonic` | `echo TECTONIC_CACHE_PATH=~/.cache/Tectonic >> $GITHUB_ENV` |
| Mac | `~/Library/Caches/Tectonic` | `echo TECTONIC_CACHE_PATH=~/Library/Caches/Tectonic >> $GITHUB_ENV` |
| Windows | `%LOCALAPPDATA%\TectonicProject\Tectonic` | <code>echo TECTONIC_CACHE_PATH=$env:LOCALAPPDATA\TectonicProject\Tectonic | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append`</code> |

## Key
By calculate the hash all .tex files (see `hashFiles('**/*.tex')`) and integrate that into the cache-`key` we can make sure, that another execution of tectonic wont change the result.

By calculate the hash all .tex files (see `hashFiles('**/*.tex')`) and integrate that into the cache-`key` we can make sure, that another execution of tectonic wont change the result.

Simpler put, as long as no `.tex` files are changing, the cache wont change.

## Restore-Keys

We change our `.tex` files but still want to use a cache? `restore-keys` to the rescue :muscle:
</br>

When we change our .tex files (either by using a new package or just change the text), the exact cache `key` wont hit. Still we want to use the cache from the previous runs, as we most likely still use the same packages. So `restore keys` will use the cache from the previous run and then (at the end of the job execution) will update the existing cache with `key`.
When we change our .tex files (either by using a new package or just change the text), the exact cache `key` wont hit. Still we want to use the cache from the previous runs, as we most likely still use the same packages. So `restore keys` will use the cache from the previous run and then (at the end of the job execution) will update the existing cache with `key`.

</br>
Thats how the cache works :)

93 changes: 93 additions & 0 deletions __tests__/release.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import {Release, ReleaseAsset} from '../src/release'

describe('release', () => {
const tectonic012Assets: ReleaseAsset[] = [
{
name: 'tectonic-0.12.0-aarch64-apple-darwin.tar.gz',
url: 'https://github.com/tectonic-typesetting/tectonic/releases/download/tectonic%400.12.0/tectonic-0.12.0-aarch64-apple-darwin.tar.gz'
},
{
name: 'tectonic-0.12.0-arm-unknown-linux-musleabihf.tar.gz',
url: 'https://github.com/tectonic-typesetting/tectonic/releases/download/tectonic%400.12.0/tectonic-0.12.0-arm-unknown-linux-musleabihf.tar.gz'
},
{
name: 'tectonic-0.12.0-i686-unknown-linux-gnu.tar.gz',
url: 'https://github.com/tectonic-typesetting/tectonic/releases/download/tectonic%400.12.0/tectonic-0.12.0-i686-unknown-linux-gnu.tar.gz'
},
{
name: 'tectonic-0.12.0-mips-unknown-linux-gnu.tar.gz',
url: 'https://github.com/tectonic-typesetting/tectonic/releases/download/tectonic%400.12.0/tectonic-0.12.0-mips-unknown-linux-gnu.tar.gz'
},
{
name: 'tectonic-0.12.0-x86_64-apple-darwin.tar.gz',
url: 'https://github.com/tectonic-typesetting/tectonic/releases/download/tectonic%400.12.0/tectonic-0.12.0-x86_64-apple-darwin.tar.gz'
},
{
name: 'tectonic-0.12.0-x86_64-pc-windows-gnu.zip',
url: 'https://github.com/tectonic-typesetting/tectonic/releases/download/tectonic%400.12.0/tectonic-0.12.0-x86_64-pc-windows-gnu.zip'
},
{
name: 'tectonic-0.12.0-x86_64-pc-windows-msvc.zip',
url: 'https://github.com/tectonic-typesetting/tectonic/releases/download/tectonic%400.12.0/tectonic-0.12.0-x86_64-pc-windows-msvc.zip'
},
{
name: 'tectonic-0.12.0-x86_64-unknown-linux-gnu.tar.gz',
url: 'https://github.com/tectonic-typesetting/tectonic/releases/download/tectonic%400.12.0/tectonic-0.12.0-x86_64-unknown-linux-gnu.tar.gz'
},
{
name: 'tectonic-0.12.0-x86_64-unknown-linux-musl.tar.gz',
url: 'https://github.com/tectonic-typesetting/tectonic/releases/download/tectonic%400.12.0/tectonic-0.12.0-x86_64-unknown-linux-musl.tar.gz'
},
{
name: 'tectonic-0.12.0-x86_64.AppImage',
url: 'https://github.com/tectonic-typesetting/tectonic/releases/download/tectonic%400.12.0/tectonic-0.12.0-x86_64.AppImage'
}
]

const tectonic012Release = new Release(
81233082,
'tectonic@0.12.0',
tectonic012Assets,
'tectonic 0.12.0'
)

describe('getAsset', () => {
it('should return .zip filename on windows', async () => {
expect(tectonic012Release.getAsset('windows')).toStrictEqual({
name: 'tectonic-0.12.0-x86_64-pc-windows-msvc.zip',
url: 'https://github.com/tectonic-typesetting/tectonic/releases/download/tectonic%400.12.0/tectonic-0.12.0-x86_64-pc-windows-msvc.zip'
})
})

it('should return .tar.gz filename on linux', async () => {
expect(tectonic012Release.getAsset('linux')).toStrictEqual({
name: 'tectonic-0.12.0-x86_64-unknown-linux-gnu.tar.gz',
url: 'https://github.com/tectonic-typesetting/tectonic/releases/download/tectonic%400.12.0/tectonic-0.12.0-x86_64-unknown-linux-gnu.tar.gz'
})
})

it('should return .tar.gz filename on mac', async () => {
expect(tectonic012Release.getAsset('darwin')).toStrictEqual({
name: 'tectonic-0.12.0-x86_64-apple-darwin.tar.gz',
url: 'https://github.com/tectonic-typesetting/tectonic/releases/download/tectonic%400.12.0/tectonic-0.12.0-x86_64-apple-darwin.tar.gz'
})
})

it('should return .AppImage filename on linux releases up to 0.10.0', async () => {
const fakeTectonic010Assets = tectonic012Assets.map(asset => ({
name: asset.name.replace(/0.12.0/g, '0.10.0'),
url: asset.url.replace(/0.12.0/g, '0.10.0')
}))
const tectonic010Release = new Release(
81233083,
'tectonic@0.10.0',
fakeTectonic010Assets,
'tectonic 0.10.0'
)
expect(tectonic010Release.getAsset('linux')).toStrictEqual({
name: 'tectonic-0.10.0-x86_64.AppImage',
url: 'https://github.com/tectonic-typesetting/tectonic/releases/download/tectonic%400.10.0/tectonic-0.10.0-x86_64.AppImage'
})
})
})
})
6 changes: 5 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"package": "ncc build --source-map --license licenses.txt",
"test": "jest",
"coverage": "jest --collectCoverage",
"update-dist": "yarn run build && yarn run package",
"all": "yarn run build && yarn run format && yarn run lint && yarn run package && yarn test"
},
"repository": {
Expand All @@ -36,7 +37,7 @@
"devDependencies": {
"@octokit/types": "7.5.1",
"@types/jest": "29.0.3",
"@types/node": "18.11.10",
"@types/node": "16.x",
"@types/semver": "7.3.13",
"@types/uuid": "8.3.4",
"@typescript-eslint/parser": "5.45.0",
Expand Down
Loading

0 comments on commit e61d40c

Please sign in to comment.