Skip to content

Commit 3abaa70

Browse files
authored
feat: add emoji generator script (#321)
* feat: add emoji generator app * chore: add workflows/emoji-data-updater * platform: ignore emoji_generator directory * feat: set output path to project directory & streamline output props * chore: update gradle-wrapper-validation.yml * chore: update android-unit-test.yml
1 parent b2d473f commit 3abaa70

16 files changed

+1236
-2
lines changed

.github/workflows/android-unit-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
- develop
99
paths-ignore:
1010
- "app/src/main/**"
11+
- "scripts/emoji_generator/**"
1112

1213
permissions:
1314
checks: write
@@ -18,7 +19,6 @@ jobs:
1819
steps:
1920
- uses: actions/checkout@v4
2021
- uses: gradle/actions/setup-gradle@v4
21-
- uses: gradle/wrapper-validation-action@v3
2222
- name: set up JDK 17
2323
uses: actions/setup-java@v4
2424
with:
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: emoji-data-updater
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "0 2 * * 5"
7+
8+
jobs:
9+
update-emoji-json:
10+
runs-on: ubuntu-latest
11+
env:
12+
VERSION: ''
13+
RELEASE_URL: ''
14+
WORKING_DIR: scripts/emoji_generator
15+
steps:
16+
- name: Checkout Repository
17+
uses: actions/checkout@v4
18+
- name: Fetch Latest Emojibase Version
19+
id: fetch_version
20+
run: |
21+
RELEASE_INFO=$(curl -s https://api.github.com/repos/milesj/emojibase/releases/latest)
22+
LATEST_RELEASE=$(echo "$RELEASE_INFO" | jq -r '.tag_name')
23+
RELEASE_URL=$(echo "$RELEASE_INFO" | jq -r '.html_url')
24+
echo "VERSION=$(echo \"$LATEST_RELEASE\" | grep -oP '(?<=emojibase-data@)\d+\.\d+\.\d+')" >> $GITHUB_ENV
25+
echo "RELEASE_URL=$RELEASE_URL" >> $GITHUB_ENV
26+
27+
- name: Setup Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: "3.10.6"
31+
32+
- name: Install Dependencies
33+
run: |
34+
pip install --upgrade pip
35+
pip install poetry
36+
poetry config virtualenvs.create true
37+
poetry install --no-root
38+
39+
- name: Run Emoji Update Script
40+
env:
41+
PYTHONUNBUFFERED: 1
42+
EMOJI_VERSION: ${{ env.VERSION }}
43+
run: |
44+
cd ${{ env.WORKING_DIR }}
45+
poetry run python emoji_generator/generator.py
46+
47+
- name: Push Changes and Create PR
48+
uses: peter-evans/create-pull-request@v7
49+
with:
50+
commit-message: "chore(deps): update emoji.json to emojibase-data@${{ env.VERSION }}"
51+
title: "Update emoji.json to emojibase-data@${{ env.VERSION }}"
52+
body: |
53+
This PR updates emoji.json to the latest version of emojibase-data: `emojibase-data@${{ env.VERSION }}`.
54+
55+
You can review the release notes [here](${{ env.RELEASE_URL }}).
56+
branch: dependencies/emoji-base-updates
57+
author: GitHub <[email protected]>
58+
delete-branch: true

.github/workflows/gradle-wrapper-validation.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v4
10-
- uses: gradle/wrapper-validation-action@v3
10+
- uses: gradle/actions/wrapper-validation@v3

scripts/emoji_generator/.gitignore

+269
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/python
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=python
3+
4+
### Python ###
5+
# Byte-compiled / optimized / DLL files
6+
__pycache__/
7+
*.py[cod]
8+
*$py.class
9+
10+
# C extensions
11+
*.so
12+
13+
# Distribution / packaging
14+
.Python
15+
build/
16+
develop-eggs/
17+
dist/
18+
downloads/
19+
eggs/
20+
.eggs/
21+
lib/
22+
lib64/
23+
parts/
24+
sdist/
25+
var/
26+
wheels/
27+
share/python-wheels/
28+
*.egg-info/
29+
.installed.cfg
30+
*.egg
31+
MANIFEST
32+
33+
# PyInstaller
34+
# Usually these files are written by a python script from a template
35+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
36+
*.manifest
37+
*.spec
38+
39+
# Installer logs
40+
pip-log.txt
41+
pip-delete-this-directory.txt
42+
43+
# Unit test / coverage reports
44+
htmlcov/
45+
.tox/
46+
.nox/
47+
.coverage
48+
.coverage.*
49+
.cache
50+
nosetests.xml
51+
coverage.xml
52+
*.cover
53+
*.py,cover
54+
.hypothesis/
55+
.pytest_cache/
56+
cover/
57+
58+
# Translations
59+
*.mo
60+
*.pot
61+
62+
# Django stuff:
63+
*.log
64+
local_settings.py
65+
db.sqlite3
66+
db.sqlite3-journal
67+
68+
# Flask stuff:
69+
instance/
70+
.webassets-cache
71+
72+
# Scrapy stuff:
73+
.scrapy
74+
75+
# Sphinx documentation
76+
docs/_build/
77+
78+
# PyBuilder
79+
.pybuilder/
80+
target/
81+
82+
# Jupyter Notebook
83+
.ipynb_checkpoints
84+
85+
# IPython
86+
profile_default/
87+
ipython_config.py
88+
89+
# pyenv
90+
# For a library or package, you might want to ignore these files since the code is
91+
# intended to run in multiple environments; otherwise, check them in:
92+
# .python-version
93+
94+
# pipenv
95+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
96+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
97+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
98+
# install all needed dependencies.
99+
#Pipfile.lock
100+
101+
# poetry
102+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
103+
# This is especially recommended for binary packages to ensure reproducibility, and is more
104+
# commonly ignored for libraries.
105+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
106+
#poetry.lock
107+
108+
# pdm
109+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
110+
#pdm.lock
111+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
112+
# in version control.
113+
# https://pdm.fming.dev/#use-with-ide
114+
.pdm.toml
115+
116+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
117+
__pypackages__/
118+
119+
# Celery stuff
120+
celerybeat-schedule
121+
celerybeat.pid
122+
123+
# SageMath parsed files
124+
*.sage.py
125+
126+
# Environments
127+
.env
128+
.venv
129+
env/
130+
venv/
131+
ENV/
132+
env.bak/
133+
venv.bak/
134+
135+
# Spyder project settings
136+
.spyderproject
137+
.spyproject
138+
139+
# Rope project settings
140+
.ropeproject
141+
142+
# mkdocs documentation
143+
/site
144+
145+
# mypy
146+
.mypy_cache/
147+
.dmypy.json
148+
dmypy.json
149+
150+
# Pyre type checker
151+
.pyre/
152+
153+
# pytype static type analyzer
154+
.pytype/
155+
156+
# Cython debug symbols
157+
cython_debug/
158+
159+
# PyCharm
160+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
161+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
162+
# and can be added to the global gitignore or merged into this file. For a more nuclear
163+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
164+
#.idea/
165+
166+
### Python Patch ###
167+
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
168+
poetry.toml
169+
170+
# ruff
171+
.ruff_cache/
172+
173+
# LSP config files
174+
pyrightconfig.json
175+
176+
# End of https://www.toptal.com/developers/gitignore/api/python
177+
178+
# Created by https://www.toptal.com/developers/gitignore/api/intellij+all
179+
# Edit at https://www.toptal.com/developers/gitignore?templates=intellij+all
180+
181+
### Intellij+all ###
182+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
183+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
184+
185+
# User-specific stuff
186+
.idea/**/workspace.xml
187+
.idea/**/tasks.xml
188+
.idea/**/usage.statistics.xml
189+
.idea/**/dictionaries
190+
.idea/**/shelf
191+
192+
# AWS User-specific
193+
.idea/**/aws.xml
194+
195+
# Generated files
196+
.idea/**/contentModel.xml
197+
198+
# Sensitive or high-churn files
199+
.idea/**/dataSources/
200+
.idea/**/dataSources.ids
201+
.idea/**/dataSources.local.xml
202+
.idea/**/sqlDataSources.xml
203+
.idea/**/dynamic.xml
204+
.idea/**/uiDesigner.xml
205+
.idea/**/dbnavigator.xml
206+
207+
# Gradle
208+
.idea/**/gradle.xml
209+
.idea/**/libraries
210+
211+
# Gradle and Maven with auto-import
212+
# When using Gradle or Maven with auto-import, you should exclude module files,
213+
# since they will be recreated, and may cause churn. Uncomment if using
214+
# auto-import.
215+
# .idea/artifacts
216+
# .idea/compiler.xml
217+
# .idea/jarRepositories.xml
218+
# .idea/modules.xml
219+
# .idea/*.iml
220+
# .idea/modules
221+
# *.iml
222+
# *.ipr
223+
224+
# CMake
225+
cmake-build-*/
226+
227+
# Mongo Explorer plugin
228+
.idea/**/mongoSettings.xml
229+
230+
# File-based project format
231+
*.iws
232+
233+
# IntelliJ
234+
out/
235+
236+
# mpeltonen/sbt-idea plugin
237+
.idea_modules/
238+
239+
# JIRA plugin
240+
atlassian-ide-plugin.xml
241+
242+
# Cursive Clojure plugin
243+
.idea/replstate.xml
244+
245+
# SonarLint plugin
246+
.idea/sonarlint/
247+
248+
# Crashlytics plugin (for Android Studio and IntelliJ)
249+
com_crashlytics_export_strings.xml
250+
crashlytics.properties
251+
crashlytics-build.properties
252+
fabric.properties
253+
254+
# Editor-based Rest Client
255+
.idea/httpRequests
256+
257+
# Android studio 3.1+ serialized cache file
258+
.idea/caches/build_file_checksums.ser
259+
260+
### Intellij+all Patch ###
261+
# Ignore everything but code style settings and run configurations
262+
# that are supposed to be shared within teams.
263+
264+
.idea/*
265+
266+
!.idea/codeStyles
267+
!.idea/runConfigurations
268+
269+
# End of https://www.toptal.com/developers/gitignore/api/intellij+all
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10.6

scripts/emoji_generator/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# emoji-generator
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .generator import *
2+
from .models import *
3+
from .utils import *
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import traceback
2+
from functools import wraps
3+
from logging import getLogger
4+
from typing import Dict, Callable, Any
5+
6+
7+
__logger = getLogger()
8+
9+
10+
def run_catching(func: Callable[..., Any]) -> Callable[..., Any]:
11+
@wraps(func)
12+
def wrapper(*args: tuple[Any, ...], **kwargs: Dict[str, Any]) -> Any:
13+
try:
14+
return func(*args, **kwargs)
15+
except Exception as e:
16+
trace = traceback.format_exc() # Get full traceback details
17+
__logger.error(f"An error occurred in '{func.__name__}': {e}")
18+
raise SystemExit(trace)
19+
20+
return wrapper

0 commit comments

Comments
 (0)