Skip to content

Commit

Permalink
v1.0.3 Support argtable3 and 2
Browse files Browse the repository at this point in the history
- Support argtable3 and 2
- Make build-able on nix
- Clean CI and build
  • Loading branch information
da-luce authored Jan 12, 2025
2 parents 3b4de66 + 45a8da0 commit fb0f0c2
Show file tree
Hide file tree
Showing 13 changed files with 355 additions and 223 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ trim_trailing_whitespace = true
based_on_style = Microsoft
max_line_length = 128
sort_includes = true

[*.{yml,yaml}]
indent_size = 2
130 changes: 94 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ on:
- main
- dev

env:
Bin: ./bin/release # Where to put release binaries
HashDir: ./hash # Where to put hashes of binaries
DepsDir: ./deps # Where to put local libs (primarily for Windows builds)

jobs:

binary:
Expand Down Expand Up @@ -56,6 +61,8 @@ jobs:

fail-fast: false
runs-on: ${{ matrix.os }}
env:
BinaryName: ${{ matrix.suffix == 'win' && format('astroterm-{0}-{1}.exe', matrix.suffix, matrix.arch) || format('astroterm-{0}-{1}', matrix.suffix, matrix.arch)}}

steps:
- name: Checkout Code
Expand Down Expand Up @@ -86,6 +93,7 @@ jobs:
# macOS Dependencies
# ------------------------------------------------------------------------

# Use argtable2 since argtable3 is only available as a dylib
- name: Install macOS Dependencies
if: matrix.suffix == 'darwin'
run: |
Expand Down Expand Up @@ -116,29 +124,32 @@ jobs:
with:
architecture: x64

# The most up to date release of PDCurses is outdated,
# so we clone directly
- name: Clone and Build PDCurses
if: matrix.suffix == 'win'
run: |
mkdir .\install\lib
mkdir .\install\include
cd .\install
mkdir ${{ env.DepsDir }}/lib
mkdir ${{ env.DepsDir }}/include
cd ${{ env.DepsDir }}
git clone https://github.com/wmcbrine/PDCurses/
cd PDCurses\wincon
cd PDCurses/wincon
nmake -f Makefile.vc WIDE=Y UTF8=Y
copy pdcurses.lib ..\..\lib
copy ..\curses.h ..\..\include
copy ..\panel.h ..\..\include
copy pdcurses.lib ../../lib
copy ../curses.h ../../include
copy ../panel.h ../../include
# Couldn't get Argtable3 to build nicely so we just use Argtable2 for Windows
- name: Download and Build Argtable2
if: matrix.suffix == 'win'
run: |
cd .\install
cd ${{ env.DepsDir }}
curl -L -o argtable2-13.tar.gz http://prdownloads.sourceforge.net/argtable/argtable2-13.tar.gz
tar -xzf argtable2-13.tar.gz
cd .\argtable2-13\src
cd ./argtable2-13\src
nmake -f Makefile.nmake
copy argtable2.lib ..\..\lib
copy argtable2.h ..\..\include
copy argtable2.lib ../../lib
copy argtable2.h ../../include
# ------------------------------------------------------------------------
# Build and test
Expand All @@ -147,10 +158,11 @@ jobs:
- name: Download BSC5
run: curl -L -o data/bsc5 http://tdc-www.harvard.edu/catalogs/BSC5 || echo "bsc5 already exists or curl failed"

# Create a static release
- name: Build
env:
CC: ${{ matrix.compiler }}
BuildFlag: ${{ matrix.coverage && '-Db_coverage=true' || '--buildtype=release'}}
BuildFlag: ${{ matrix.coverage && '-Db_coverage=true' || '--buildtype=release -Dprefer_static=true'}}
run: |
meson setup build $BuildFlag
meson compile --verbose -C build
Expand Down Expand Up @@ -179,49 +191,95 @@ jobs:
# Generate Hash
# ------------------------------------------------------------------------

# FIXME: annoying logic to ensure artifact and hash name are the same

- name: Generate Hash
env:
ArtifactName: astroterm-${{ matrix.suffix }}-${{ matrix.arch }}
run: |
mkdir -p ./hash
${{ matrix.suffix == 'win' && 'certutil -hashfile build/astroterm.exe SHA256' || 'shasum -a 256 build/astroterm' }} > ${{ matrix.suffix == 'win' && format('./hash/{0}.exe.sha256', env.ArtifactName) || format('./hash/{0}.sha256', env.ArtifactName) }}
mkdir -p ${{ env.HashDir }}
${{ matrix.suffix == 'win' && 'certutil -hashfile build/astroterm.exe SHA256' || 'shasum -a 256 build/astroterm' }} > ${{ env.HashDir }}/${{ env.BinaryName }}.sha256
- name: Upload Hash
if: matrix.coverage != true
uses: actions/upload-artifact@v4
env:
ArtifactName: astroterm-${{ matrix.suffix }}-${{ matrix.arch }}
with:
name: ${{ matrix.suffix == 'win' && format('{0}.exe.sha256', env.ArtifactName) || format('{0}.sha256', env.ArtifactName) }}
path: ./hash
name: ${{ env.BinaryName }}.sha256
path: ${{ env.HashDir }}/*

# ------------------------------------------------------------------------
# Upload Binary
# ------------------------------------------------------------------------

- name: Rename Binary File
if: matrix.coverage == false
env:
ArtifactName: astroterm-${{ matrix.suffix }}-${{ matrix.arch }}
run: |
mkdir -p ./bin/release
mv ${{ matrix.suffix == 'win' && 'build/astroterm.exe' || 'build/astroterm' }} ${{ matrix.suffix == 'win' && format('./bin/release/{0}.exe', env.ArtifactName) || format('./bin/release/{0}', env.ArtifactName) }}
mkdir -p ${{env.Bin}}
mv ${{ matrix.suffix == 'win' && 'build/astroterm.exe' || 'build/astroterm' }} ${{env.Bin}}/${{env.BinaryName}}
- name: Upload Binary
if: matrix.coverage == false
env:
ArtifactName: astroterm-${{ matrix.suffix }}-${{ matrix.arch }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.suffix == 'win' && format('{0}.exe', env.ArtifactName) || format('{0}', env.ArtifactName) }}
path: ./bin/release
name: ${{ env.BinaryName }}
path: ${{env.Bin}}
if-no-files-found: error

# Ensure binaries are standalone
run:
needs: binary
strategy:
matrix:
include:

# astroterm-linux-x86_64
- os: ubuntu-20.04
suffix: linux
arch: x86_64

# astroterm-darwin-aarch64
- os: macos-latest
suffix: darwin
arch: aarch64

# astroterm-darwin-x86_64
- os: macos-13
suffix: darwin
arch: x86_64

# astroterm-win-x86_64
- os: windows-latest
suffix: win
arch: x86_64

fail-fast: false
runs-on: ${{ matrix.os }}
env:
BinaryName: ${{ matrix.suffix == 'win' && format('astroterm-{0}-{1}.exe', matrix.suffix, matrix.arch) || format('astroterm-{0}-{1}', matrix.suffix, matrix.arch)}}

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Download Release Binary
uses: actions/download-artifact@v4
with:
pattern: ${{ env.BinaryName }}*
path: ${{env.Bin}}
merge-multiple: true

- name: List Release Directiory
run: |
ls -l ${{env.Bin}}
- name: Set Executable Permissions
if: matrix.suffix != 'win'
run: |
chmod +x ${{env.Bin}}/${{ env.BinaryName }}
- name: Run Binary
run: |
${{env.Bin}}/${{ env.BinaryName }} -v
code-quality:
runs-on: ubuntu-latest
needs: binary
needs: run
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -264,7 +322,7 @@ jobs:

publish-release:
runs-on: ubuntu-latest
needs: [binary, code-quality, upload-coverage]
needs: [binary, run, code-quality, upload-coverage]
permissions:
contents: write
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
Expand All @@ -274,13 +332,13 @@ jobs:
uses: actions/download-artifact@v4
with:
pattern: astroterm-*
path: ./bin/release
path: ${{env.Bin}}
merge-multiple: true

- name: Verify Version Consistency
run: |
TAG_VERSION="${{ github.ref_name }}"
BINARY_PATH="./bin/release/astroterm-linux-x86_64"
BINARY_PATH="${{env.Bin}}/astroterm-linux-x86_64"
# Ensure the binary is executable
chmod +x "$BINARY_PATH"
Expand All @@ -303,12 +361,12 @@ jobs:
- name: List files in release folder
run: ls -al ./bin/release
run: ls -al ${{env.Bin}}

- name: Update GitHub Release
uses: ncipollo/release-action@58ae73b360456532aafd58ee170c045abbeaee37 # v1.10.0
with:
artifacts: ./bin/release/*
artifacts: ${{env.Bin}}/*
generateReleaseNotes: true
draft: true
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
"editor.defaultFormatter": "xaver.clang-format",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
}
"C_Cpp.default.compileCommands": "/Users/sixsa/code/astroterm/build/compile_commands.json",
"C_Cpp.default.configurationProvider": "mesonbuild.mesonbuild",
}
41 changes: 21 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ Several installation methods are provided based on your platform. If none of the
1. Download the latest executable using `wget`

```sh
wget -O astroterm-linux-x86_64 "https://github.com/da-luce/astroterm/releases/latest/download/astroterm-linux-x86_64"
wget -O astroterm "https://github.com/da-luce/astroterm/releases/latest/download/astroterm-linux-x86_64"
```

2. Run the executable

```sh
chmod +x ./astroterm-linux-x86_64
./astroterm-linux-x86_64
chmod +x ./astroterm
./astroterm
```

### MacOS
Expand All @@ -70,7 +70,7 @@ brew install astroterm
1. Download the latest executable for your system architecture using `wget`

```sh
wget -O astroterm-darwin-<arch> "https://github.com/da-luce/astroterm/releases/latest/download/astroterm-darwin-<arch>"
wget -O astroterm "https://github.com/da-luce/astroterm/releases/latest/download/astroterm-darwin-<arch>"
```

- Replace `<arch>` with the appropriate architecture:
Expand All @@ -80,8 +80,8 @@ brew install astroterm
2. Run the executable

```sh
chmod +x ./astroterm-darwin-<arch>
./astroterm-darwin-<arch>
chmod +x ./astroterm
./astroterm
```

### Windows
Expand All @@ -91,13 +91,13 @@ brew install astroterm
1. Download the latest `.exe` file using PowerShell's `Invoke-WebRequest`:
```powershell
Invoke-WebRequest -Uri "https://github.com/da-luce/astroterm/releases/latest/download/astroterm-win-x86_64.exe" -OutFile "astroterm-win-x86_64.exe"
Invoke-WebRequest -Uri "https://github.com/da-luce/astroterm/releases/latest/download/astroterm-win-x86_64.exe" -OutFile "astroterm.exe"
```
2. Run the `.exe`
```powershell
.\astroterm-win-x86_64.exe
.\astroterm.exe
```
Or, download via the [Releases Page](https://github.com/da-luce/astroterm/releases).
Expand Down Expand Up @@ -203,32 +203,33 @@ Usage: astroterm [OPTION]...
-o, --longitude=<degrees> Observer longitude [-180°, 180°] (default: 0.0)
-d, --datetime=<yyyy-mm-ddThh:mm:ss>
Observation datetime in UTC
-t, --threshold=<float> Only render stars brighter than this magnitude (def
ault: 5.0)
-t, --threshold=<float> Only render stars brighter than this magnitude
(default: 5.0)
-l, --label-thresh=<float>
Label stars brighter than this magnitude (default:
0.25)
-f, --fps=<int> Frames per second (default: 24)
-s, --speed=<float> Animation speed multiplier (default: 1.0)
-c, --color Enable terminal colors
-C, --constellations Draw constellation stick figures. Note: a constella
tion is only drawn if all stars in the figure are o
ver the threshold
-C, --constellations Draw constellation stick figures. Note: a
constellation is only drawn if all stars in the
figure are over the threshold
-g, --grid Draw an azimuthal grid
-u, --unicode Use unicode characters
-q, --quit-on-any Quit on any keypress (default is to quit on 'q' or
'ESC' only)
-m, --metadata Display metadata
-r, --aspect-ratio=<float>
Override the calculated terminal cell aspect ratio.
Use this if your projection is not 'square.' A valu
e around 2.0 works well for most cases
Use this if your projection is not 'square.' A value
around 2.0 works well for most cases
-h, --help Print this help message
-i, --city=<city_name> Use the latitude and longitude of the provided city
. If the name contains multiple words, enclose the
name in single or double quotes. For a list of avai
lable cities, see: https://github.com/da-luce/astro
term/blob/main/data/cities.csv
-i, --city=<city_name> Use the latitude and longitude of the provided city.
If the name contains multiple words, enclose the
name in single or double quotes. For a list of
available cities, see:
https://github.com/da-luce/astroterm/blob/main/data/
cities.csv
-v, --version Display version info and exit
```
Expand Down
6 changes: 1 addition & 5 deletions data/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
project_header_files += [
files('keplerian_elements.h'),
]

project_source_files += [
files('keplerian_elements.c'),
]
]
12 changes: 0 additions & 12 deletions include/meson.build

This file was deleted.

Loading

0 comments on commit fb0f0c2

Please sign in to comment.