Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
Added publish workflow. Added make build-image COMMIT_HASH feature
  • Loading branch information
1NepuNep1 committed Jan 17, 2025
2 parents 5c2d97f + 85ec673 commit 4ddf7de
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 7 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: publish

on:
workflow_dispatch:
inputs:
commit-hash:
description: "COMMIT_HASH"
required: false
type: string
default: "default"

jobs:
build-and-optionally-publish:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Build & test (always)
run: |
if [ "${{ github.event.inputs.commit-hash }}" = "default" ]; then
make build-image
else
make build-image COMMIT_HASH=${{ github.event.inputs.commit-hash }}
fi
make all
- name: Publish (optional)
if: ${{ github.event.inputs.commit-hash != 'default' }}
run: |
echo "Publishing changes..."
git config --global user.email "robot@umbrella";
git config --global user.name "robot";
git commit -am "Auto-update with COMMIT_HASH=${{ github.event.inputs.commit-hash }}" || echo "Nothing to commit"
git push
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ RUN apt-get update && apt-get install -y \
sed \
&& rm -rf /var/lib/apt/lists/*

ENV ANTLR_VERSION=4.13.2
ENV COMMIT_HASH=99ceb562485efe2cefe47db042606e38259640c6
ARG ANTLR_VERSION
ARG COMMIT_HASH

ENV ANTLR_VERSION=$ANTLR_VERSION
ENV COMMIT_HASH=$COMMIT_HASH

ENV ANTLR_VERSION=4.13.2
RUN curl -O https://www.antlr.org/download/antlr-${ANTLR_VERSION}-complete.jar
Expand All @@ -22,4 +25,4 @@ RUN curl -L -o YQL.g4 https://raw.githubusercontent.com/ydb-platform/ydb/${COMMI

RUN sed -i "s/grammar SQLv1Antlr4/grammar YQL/g; s/@GRAMMAR_STRING_CORE_SINGLE@/~('\\\'\' | '\\\\\\\\') | ('\\\\\\\\' .)/g; s/@GRAMMAR_STRING_CORE_DOUBLE@/~('\\\"\' | '\\\\\\\\') | ('\\\\\\\\' .)/g; s/@GRAMMAR_MULTILINE_COMMENT_CORE@/./g" YQL.g4

CMD ["bash"]
CMD ["bash"]
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
IMAGE_NAME=yql-antlr-parser:latest
ANTLR_VERSION=4.13.2
CURRENT_DIR := $(shell pwd)

ANTLR_VERSION = 4.13.2
COMMIT_HASH ?= 99ceb562485efe2cefe47db042606e38259640c6

.PHONY: build-image clean go python dotnet java all go_clean py_clean build-image

all: go python dotnet java
Expand All @@ -19,13 +21,12 @@ dotnet: build-image
docker run --rm -v "$(CURRENT_DIR)/dotnet":/workspace/dotnet $(IMAGE_NAME) \
java -jar /antlr-${ANTLR_VERSION}-complete.jar -Dlanguage=CSharp -package YQLAntlr4Parser -o dotnet YQL.g4


java: build-image
docker run --rm -v "$(CURRENT_DIR)/java":/workspace/java $(IMAGE_NAME) \
java -jar /antlr-${ANTLR_VERSION}-complete.jar -Dlanguage=Java -package yql.antlr4.parser -o java YQL.g4

build-image:
docker build -t $(IMAGE_NAME) .
build-image:
docker build --build-arg ANTLR_VERSION=$(ANTLR_VERSION) --build-arg COMMIT_HASH=$(COMMIT_HASH) -t $(IMAGE_NAME) .

clean: go_clean python_clean dotnet_clean java_clean

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ This project provides different languages code generation of YQL parser using AN
```bash
make build-image
```
_Optional:_ can be generated with prefered COMMIT_HASH from [YDB Repo](https://github.com/ydb-platform/ydb/blob/main/yql/essentials/sql/v1/SQLv1Antlr4.g.in):
```bash
make build-image COMMIT_HASH=yourcommithashhere
```

- **`clean`**
Cleans all generated files for all languages
Expand Down

0 comments on commit 4ddf7de

Please sign in to comment.