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

Add support for aarch64 #369

Merged
merged 21 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a6fe908
Add architecture input
xRuiAlves Mar 13, 2023
b1547ee
Add architecture input to download base url
xRuiAlves Mar 13, 2023
8092183
Refactor zip binary extraction to reflect architecture
xRuiAlves Mar 13, 2023
76c5776
Fix linting issues
xRuiAlves Mar 13, 2023
54a1de7
Update generated dist
xRuiAlves Mar 13, 2023
6ad9f82
Add architecture validation to main run function
xRuiAlves Mar 13, 2023
e50ee29
Fix unused parameter in 'isValidArchitecture' function
xRuiAlves Mar 13, 2023
d26ebc9
Update generated dist
xRuiAlves Mar 13, 2023
3e7e9e8
Rename 'arc' to 'archive'
xRuiAlves Mar 13, 2023
0ed2533
Add 'architecture' input variable documentation to README
xRuiAlves Mar 13, 2023
82d6d62
Add 'architecture' input specification to README example with custom …
xRuiAlves Mar 13, 2023
097ab58
Update test workflow with architectures
xRuiAlves Mar 13, 2023
75e363e
Add architecture input to action yml definition
xRuiAlves Mar 13, 2023
bb1def8
Revert "Add 'architecture' input variable documentation to README"
xRuiAlves Mar 13, 2023
9b87586
Revert "Add architecture input to action yml definition"
xRuiAlves Mar 13, 2023
932bcae
Revert "Update test workflow with architectures"
xRuiAlves Mar 13, 2023
3889adb
Revert "Add 'architecture' input specification to README example with…
xRuiAlves Mar 13, 2023
77d4c3c
Compute architecture from process.arch
xRuiAlves Mar 13, 2023
f97bad3
Revert "Update generated dist"
xRuiAlves Mar 13, 2023
60f923f
Revert "Update generated dist"
xRuiAlves Mar 13, 2023
e64d66d
Fix linting issues
xRuiAlves Mar 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
jvm: ['8', '11']
architecture: ['x86_64', 'aarch6']
xRuiAlves marked this conversation as resolved.
Show resolved Hide resolved
steps:
- uses: actions/checkout@v3

Expand All @@ -29,6 +30,7 @@ jobs:
with:
jvm: ${{ matrix.jvm }}
apps: sbt sbtn ammonite bloop:1.4.11
architecture: ${{ matrix.architecture }}

# - uses: coursier/cache-action@v5
- run: echo cs-version=${{ steps.cs-setup.outputs.cs-version }}
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Inspired by [olafurpg/setup-scala](https://github.com/olafurpg/setup-scala) and
- if left empty either the existing JVM will be used or Coursier will install its default JVM.
- `apps` (optional): Scala apps to install (`sbtn` by default)
- space separated list of app names (from the [main channel](https://github.com/coursier/apps))
- `architecture` (optional): Coursier architecture to install binaries for
- valid values: `x86_64`, `aarch6` (defaults to `x86_64`)

### Example with custom inputs

Expand All @@ -30,6 +32,7 @@ Inspired by [olafurpg/setup-scala](https://github.com/olafurpg/setup-scala) and
with:
jvm: adopt:11
apps: sbtn bloop ammonite
architecture: aarch64
```

## Outputs
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ inputs:
description: 'Coursier version to install'
required: false
default: ''
architecture:
description: 'Coursier architecture to install'
required: false
default: ''
outputs:
cs-version:
description: 'Version of the installed Coursier'
Expand Down
19 changes: 13 additions & 6 deletions 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.

41 changes: 27 additions & 14 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ import * as os from 'os'
import * as path from 'path'
import * as tc from '@actions/tool-cache'

let csVersion = core.getInput('version')
if (!csVersion) csVersion = '2.1.0-M7-39-gb8f3d7532'
const validArchitectures = Object.freeze(['x86_64', 'aarch6'])

const csVersion = core.getInput('version') || '2.1.0-M7-39-gb8f3d7532'
const architecture = core.getInput('architecture') || validArchitectures[0]

const coursierVersionSpec = csVersion

function isValidArchitecture(arch: string): Boolean {
return validArchitectures.includes(arch)
}

async function execOutput(cmd: string, ...args: string[]): Promise<string> {
let output = ''
const options = {
Expand All @@ -23,28 +29,28 @@ async function execOutput(cmd: string, ...args: string[]): Promise<string> {
}

async function downloadCoursier(): Promise<string> {
const baseUrl = `https://github.com/coursier/coursier/releases/download/v${csVersion}/cs-x86_64`
const baseUrl = `https://github.com/coursier/coursier/releases/download/v${csVersion}/cs-${architecture}`
let csBinary = ''
switch (process.platform) {
case 'linux': {
const guid = await tc.downloadTool(`${baseUrl}-pc-linux.gz`)
const arc = `${guid}.gz`
await cli.exec('mv', [guid, arc])
csBinary = arc
const archive = `${guid}.gz`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed these arc variables to archive - With the introduction of the new architecture variable, arc could be ambiguous, and the renaming enhances clarity on this.

await cli.exec('mv', [guid, archive])
csBinary = archive
break
}
case 'darwin': {
const guid = await tc.downloadTool(`${baseUrl}-apple-darwin.gz`)
const arc = `${guid}.gz`
await cli.exec('mv', [guid, arc])
csBinary = arc
const archive = `${guid}.gz`
await cli.exec('mv', [guid, archive])
csBinary = archive
break
}
case 'win32': {
const guid = await tc.downloadTool(`${baseUrl}-pc-win32.zip`)
const arc = `${guid}.zip`
await cli.exec('mv', [guid, arc])
csBinary = arc
const archive = `${guid}.zip`
await cli.exec('mv', [guid, archive])
csBinary = archive
break
}
default:
Expand All @@ -57,8 +63,8 @@ async function downloadCoursier(): Promise<string> {
}
if (csBinary.endsWith('.zip')) {
const destDir = csBinary.slice(0, csBinary.length - '.zip'.length)
await cli.exec('unzip', ['-j', csBinary, 'cs-x86_64-pc-win32.exe', '-d', destDir])
csBinary = `${destDir}\\cs-x86_64-pc-win32.exe`
await cli.exec('unzip', ['-j', csBinary, `cs-${architecture}-pc-win32.exe`, '-d', destDir])
csBinary = `${destDir}\\cs-${architecture}-pc-win32.exe`
}
await cli.exec('chmod', ['+x', csBinary])
return csBinary
Expand All @@ -79,6 +85,13 @@ async function cs(...args: string[]): Promise<string> {

async function run(): Promise<void> {
try {
if (!isValidArchitecture(architecture)) {
core.setFailed(
`Invalid architecture specified. Valid options are: ${validArchitectures.join(', ')}`,
)
return
}

await core.group('Install Coursier', async () => {
await cs('--help')
core.setOutput('cs-version', csVersion)
Expand Down