Skip to content

Commit

Permalink
feat(greetings): add check for already greeted issues and PRs
Browse files Browse the repository at this point in the history
Add a step to the GitHub Actions workflow to check if an issue or PR has already
been greeted before proceeding with the greeting. This prevents duplicate greetings
and makes the workflow more efficient.
  • Loading branch information
AstroAir committed Jun 26, 2024
1 parent 99dacdd commit d5f3307
Show file tree
Hide file tree
Showing 50 changed files with 2,484 additions and 1,223 deletions.
51 changes: 29 additions & 22 deletions .github/workflows/greetings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,23 @@ jobs:
issues: write
pull-requests: write
steps:
# Check if the issue or PR already has the greeted label
- name: Check if Already Greeted
id: check_greeted
uses: actions/github-script@v6
with:
result-encoding: string
script: |
const labels = await github.rest.issues.listLabelsOnIssue({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
});
return labels.data.some(label => label.name === 'greeted');
# Greeting for first interaction using actions/first-interaction
- name: First Interaction Greeting
if: steps.check_greeted.outputs.result == 'false'
uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -19,7 +34,7 @@ jobs:

# General greeting for every new issue
- name: Greet Every Issue
if: github.event_name == 'issues'
if: github.event_name == 'issues' && steps.check_greeted.outputs.result == 'false'
uses: actions/github-script@v6
with:
script: |
Expand All @@ -29,11 +44,11 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo,
body: issueComment
})
});
# General greeting for every new pull request
- name: Greet Every PR
if: github.event_name == 'pull_request_target'
if: github.event_name == 'pull_request_target' && steps.check_greeted.outputs.result == 'false'
uses: actions/github-script@v6
with:
script: |
Expand All @@ -44,33 +59,25 @@ jobs:
repo: context.repo.repo,
body: prComment,
event: 'COMMENT'
})
});
# Add labels to new issues and PRs
- name: Label New Issues and PRs
if: steps.check_greeted.outputs.result == 'false'
uses: actions/github-script@v6
with:
script: |
const labels = ['needs-triage'];
if (context.eventName === 'issues') {
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labels
})
} else if (context.eventName === 'pull_request_target') {
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labels
})
}
const labels = ['needs-triage', 'greeted'];
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labels
});
# Auto Assign Reviewers based on the time of day
- name: Auto-assign Reviewers Based on Time of Day
if: github.event_name == 'pull_request_target'
if: github.event_name == 'pull_request_target' && steps.check_greeted.outputs.result == 'false'
uses: actions/github-script@v6
with:
script: |
Expand All @@ -82,4 +89,4 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo,
reviewers: reviewers
})
});
11 changes: 5 additions & 6 deletions .github/workflows/windows-mingw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ on:
branches:
- 'master'
- 'dev'
- 'reborn'
pull_request:
branches:
- 'master'
- 'dev'
- 'reborn'

env:
# Path to the solution file relative to the root of the project.
Expand Down Expand Up @@ -43,7 +45,6 @@ jobs:
update: true
install: >-
mingw-w64-${{matrix.env}}-openssl
base-devel
mingw-w64-${{matrix.env}}-cmake
mingw-w64-${{matrix.env}}-gcc
Expand All @@ -58,9 +59,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Build INDI Core
- name: Build and Test
run: |
mkdir build
cd build
cmake ..
cmake --build .
./scripts/build_win.sh
./scripts/test_win.sh
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ test
*.xml

.xmake
.cache
4 changes: 4 additions & 0 deletions .sonarlint/connectedMode.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"sonarCloudOrganization": "elementastro",
"projectKey": "ElementAstro_Lithium"
}
148 changes: 32 additions & 116 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Lithium
# Lithium - The Lightweight Suite for Astronomical Imaging

<p align="center">
<img src="https://img.shields.io/badge/dialect-C%2B%2B20-blue">
Expand All @@ -15,138 +15,54 @@
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=ElementAstro_Lithium&metric=bugs)](https://sonarcloud.io/summary/new_code?id=ElementAstro_Lithium)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=ElementAstro_Lithium&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=ElementAstro_Lithium)

## Introduction
## Overview

Lithium, a lively and lightweight astrophotography terminal.
The Lithium project is designed as a comprehensive, lightweight platform for astronomy enthusiasts and professionals alike, offering not just capture software but also serving as a device control server, system manager, and a platform for extensive customization, adaptable to various applications and research domains.

Features:
## Key Features

- Can be used as imaging software, device server, and system manager.
- Based on the latest C++20 standard, providing efficient functionality implementation (compatible with some C++17 features).
- Supports open loading, allowing dynamic loading of C++ dynamic libraries for hot updates.
- Built-in optimized Chaiscript parsing engine, providing flexible script support.
- Supports various types of plugins, facilitating feature expansion.
- Cross-platform compatibility, fully supporting Windows and Linux operating systems.
- Lightweight software design, while maintaining excellent performance.
- Provides a rich API, covering all necessary functions for astrophotography. ~~If not? Mods!~~
- Supports complex shooting sequences, enabling a programmable user experience.
- Uses the GPL3 open source license, **where the world belongs to open source**
- **Versatile Functionality**: Supports full-spectrum application from image acquisition to device management and system operations.
- **Contemporary Language Standard**: Built using the latest C++20 standard with compatibility for select C++23 features, ensuring modernity and efficiency in code.
- **Dynamic Module Loading**: Enables hot updates through C++ dynamic libraries, facilitating instant expansion of capabilities and enhancing flexibility.
- **Embedded Scripting Engine**: Integrates a high-performance pocketpy interpreter supporting Python scripts for rapid development of tailored logic.
- **Broad Platform Compatibility**: Fully supports Windows and Linux environments (including x86_64 and ARM architectures), with partial support for MacOS.
- **Comprehensive APIs and Components**: Offers a wide range of APIs and functional components that cater to diverse astronomical imaging needs, encouraging users to develop modules for missing functionalities.
- **Open-Source Licensing Model**: Adheres to the GPLv3 license, fostering community sharing and collaboration while allowing for proprietary plugins to protect business-sensitive code.
- **Educational and Inspirational**: Encourages learning and innovation through high-quality code examples and documentation, promoting knowledge dissemination and skill enhancement.

## About Mod/Plugin
## Building Instructions

In Lithium, the component function is the most special function, providing a mod mechanism similar to Minecraft. The component function supports dynamic addition and insertion of functions, but due to the limitations of C++, we have imposed certain restrictions on the insertion of components to ensure system stability and security.
### System Preparation

### Form of Components
#### Windows

- Injective Components: These components replace the implemented functions in `Lithium`. They inject `shared_ptr` into each Manager (similar to `ConfigManager`). The target of the injected function is the same as that of the Manager that has been injected into `GlobalPtrManager`. Components in this form can flexibly replace existing functions.

- Independent Components: These components use a distributed architecture and run in independent processes to ensure system security. When it is necessary to process sensitive data or perform complex calculations, these independent components can provide additional protection and isolation. To increase the security of components, `Lithium` also provides sandboxing functionality.

It should be noted that except for injective and independent components, other forms of components will be considered illegal and unsupported for loading, and will be directly ignored by the system.

### Component Levels

- Addon: The highest level of component, containing a series of Modules and Components

- Module: A module containing a dynamic library of an indefinite number of Components (depending on the platform)

- Component: A `shared_ptr` of a specific actual function or an executable function

All functions are declared in `package.json` for ease of use.

## How to build

### Install dependencies

Although efforts have been made to minimize the use of libraries, a few dependencies still need to be installed.

#### On Windows
It is recommended to use the MSYS2 environment and leverage the Tsinghua University Open Source Software Mirror for expedited downloads. The following commands install necessary dependencies:

```shell
sed -i "s#https\?://mirror.msys2.org/#https://mirrors.tuna.tsinghua.edu.cn/msys2/#g" /etc/pacman.d/mirrorlist*
pacman -Syu
pacman -S mingw-w64-x86_64-toolchain
pacman -S mingw-w64-x86_64-dlfcn
pacman -S mingw-w64-x86_64-cfitsio
pacman -S mingw-w64-x86_64-cmake
pacman -S mingw-w64-x86_64-libzip
pacman -S mingw-w64-x86_64-zlib
pacman -S mingw-w64-x86_64-fmt
pacman -S mingw-w64-x86_64-libnova
pacman -S mingw-w64-x86_64-gsl

# for test
pacman -S mingw-w64-x86_64-gtest
```

#### On Ubuntu or other similar Linux platforms (No INDI needed)
# Add Tsinghua University mirror source
sed -i 's|https://mirror.msys2.org/|https://mirrors.tuna.tsinghua.edu.cn/msys2/|g' /etc/pacman.d/mirrorlist.mingw64
sed -i 's|https://mirror.msys2.org/|https://mirrors.tuna.tsinghua.edu.cn/msys2/|g' /etc/pacman.d/mirrorlist

```shell
sudo apt-get update && sudo apt-get upgrade -y
sudo apt install gcc g++ cmake
sudo apt install libcfitsio-dev zlib1g-dev libssl-dev libzip-dev libnova-dev libfmt-dev libudev-dev
```

Alternatively, you can directly run the provided script according to your platform:

```shell
sudo sh scripts/build_ci.sh
sh scripts/build_win.sh
```

#### Update GCC and Cmake

Unfortunately, the newest GCC and CMake are not available on Github Codespace, so we must install them manually.

```shell
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update
sudo apt-get install gcc-13 g++-13 # GCC13 is the best choice, clang is alse OK

wget https://cmake.org/files/v3.28/cmake-3.28.0-rc5.tar.gz
tar -zxvf cmake-3.28.0-rc5.tar.gz
cd cmake-3.28.0-rc5
./bootstrap && make && sudo make install

#install newest clang-format
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo nano /etc/apt/sources.list
#deb http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main
#deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main
sudo apt install -y clang-format-17
# Update system packages and install build tools and dependencies
pacman -Syu
pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-dlfcn mingw-w64-x86_64-cfitsio mingw-w64-x86_64-cmake mingw-w64-x86_64-libzip mingw-w64-x86_64-zlib mingw-w64-x86_64-fmt mingw-w64-x86_64-libnova make mingw-w64-x86_64-gtest
```

Build the code:
#### Ubuntu/Debian

```shell
mkdir build && cd build
cmake ..
make -j4 or cmake --build . -j4

./lithium_server
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install build-essential cmake libcfitsio-dev zlib1g-dev libssl-dev libzip-dev libfmt-dev
```

Everything is very simple. The entire process is straightforward.
Alternatively, utilize the provided quick-build scripts to streamline the process.

Here is a poem adapted from a quote :
### Building Steps

```txt
Learning requires not mere imagination,
Nor can it be attained through mediocre dedication.
It is through diligent accumulation,
That we shall grow in our education.
Our efforts may falter and fail,
But we must not surrender and bail.
We shall not halt our stride for fear of stumbling,
For setbacks are the price of pursuing enlightenment.
On this quest for truth, we shall encounter obstacles and doubts,
Yet we shall keep our resolve to seek understanding throughout.
Let us nurture a heart that yearns for wisdom and grace,
And never lose sight of this noble race.
```
1. **Create Build Directory**: `mkdir build && cd build`
2. **Configure Project**: `cmake ..`
3. **Compile and Execute**: Use `make -jN` or `cmake --build . --parallel N` commands to compile in parallel, where N denotes the number of threads. Afterwards, launch the program via `./lithium_server`.

## Technical Support
### Intellectual Inspiration

[![SonarCloud](https://sonarcloud.io/images/project_badges/sonarcloud-orange.svg)](https://sonarcloud.io/summary/new_code?id=ElementAstro_Lithium)
Embarking on the journey with Lithium, we embrace curiosity and an unwavering pursuit of knowledge, echoing the adapted verse which reminds us that every attempt, though fraught with challenges and setbacks, is a necessary step toward wisdom and understanding. Together, let us navigate the vast cosmos of astronomical imaging, our technology the vessel, innovation our sail, advancing relentlessly forward.
Loading

0 comments on commit d5f3307

Please sign in to comment.