From a419a6c4cb5442b378f09a5d4f334ad54df1474a Mon Sep 17 00:00:00 2001 From: Dimo Karaivanov Date: Tue, 31 Jan 2023 17:58:40 +0200 Subject: [PATCH] GitHub actions (#167) * added a github workflow for closing stale issues * added github PR validation workflows * fixed the dictionary validator missing digits in words * fixed the build failing completely when there no git tags * updated androidx.room 2.4.3 -> 2.5.0 --- .github/workflows/build.yml | 19 +++++++++++++++++++ .github/workflows/close-stale-issues.yml | 22 ++++++++++++++++++++++ build.gradle | 24 +++++++++++++++--------- 3 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/close-stale-issues.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..6cd79fcf --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,19 @@ +name: Build the Project + +on: [pull_request] + +jobs: + build: + runs-on: ubuntu-latest + steps: + # setup + - name: Checkout project sources + uses: actions/checkout@v2 + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + # validation + - name: Validate Dictionaries + run: ./gradlew validateDictionaries + - name: Build Release APK + run: ./gradlew assemble diff --git a/.github/workflows/close-stale-issues.yml b/.github/workflows/close-stale-issues.yml new file mode 100644 index 00000000..fe2910a3 --- /dev/null +++ b/.github/workflows/close-stale-issues.yml @@ -0,0 +1,22 @@ +name: Close inactive issues +on: + schedule: + - cron: "21 0 * * *" + +jobs: + close-issues: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - uses: actions/stale@v4 + with: + days-before-issue-stale: 100 + days-before-issue-close: 100 + stale-issue-label: "stale" + stale-issue-message: "This issue is stale because it has been open for 100 days with no activity." + close-issue-message: "This issue was closed because it has been inactive for 100 days since being marked as stale." + days-before-pr-stale: -1 + days-before-pr-close: -1 + repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.gradle b/build.gradle index 749807ba..cbdbf9b8 100644 --- a/build.gradle +++ b/build.gradle @@ -12,8 +12,8 @@ apply plugin: 'com.android.application' dependencies { implementation "androidx.core:core:1.9.0" implementation 'androidx.preference:preference:1.2.0' - implementation "androidx.room:room-runtime:2.4.3" - annotationProcessor "androidx.room:room-compiler:2.4.3" + implementation "androidx.room:room-runtime:2.5.0" + annotationProcessor "androidx.room:room-compiler:2.5.0" } repositories { @@ -50,18 +50,24 @@ def getVersionCode = { -> def getVersionName = { -> // major version - String versionTagsCount = execThing('git tag --list v[0-9]*').split('\n').size() + String versionTagsRaw = execThing('git tag --list v[0-9]*') + int versionTagsCount = versionTagsRaw == "" ? 0 : versionTagsRaw.split('\n').size() // minor version - String lastVersionTag = execThing('git describe --match v[0-9]* --tags --abbrev=0') - String gitLogResult = execThing("git log $lastVersionTag..HEAD --oneline") - String commitsSinceLastTag = gitLogResult == '' ? "0" : gitLogResult.split('\n').size() + String commitsSinceLastTag = "0" + if (versionTagsCount > 1) { + println "VERSION TAG: " + versionTagsCount + String lastVersionTag = execThing('git describe --match v[0-9]* --tags --abbrev=0') + String gitLogResult = execThing("git log $lastVersionTag..HEAD --oneline") + commitsSinceLastTag = gitLogResult == '' ? "0" : gitLogResult.split('\n').size() + } + // the commit we are building from // beta string, if this is a beta - String lastTagName = execThing('git describe --tags --abbrev=0') - String lastTagHash = execThing("git log -1 --format=%h $lastTagName") + String lastTagName = (execThing('git tag --list') == "") ? "" : execThing('git describe --tags --abbrev=0') + String lastTagHash = (lastTagName == "") ? "" : execThing("git log -1 --format=%h $lastTagName") String betaString = lastTagHash == getCurrentGitHash() && lastTagName.contains("-beta") ? '-beta' : '' return "$versionTagsCount.$commitsSinceLastTag$betaString" @@ -175,7 +181,7 @@ task validateDictionaries { errors += "Dictionary '" + file.name + "' is invalid. Found out-of-range word frequency: '" + frequency + "' on line " + lineNumber + ". Frequency must be a non-negative integer. \n" } - if (word.matches("\\d")) { + if (word.matches("(\\d.+?|.+?\\d|\\d)")) { errorCount++ errors += "Dictionary '" + file.name + "' is invalid. Found numbers on line " + lineNumber + ". Please, remove all numbers.\n" }