From 65127d3fa902be25faacb57ed5efc539f37da146 Mon Sep 17 00:00:00 2001 From: Kevin David Date: Tue, 6 Aug 2024 00:08:17 -0400 Subject: [PATCH] Introduce Actions workflow to test without building (#20) This should prevent the class of issue that happened after https://github.com/kevin-david/zipalign-sign-android-release/pull/16 was merged, which broke the Action externally. --- .github/shared/functional-tests/action.yml | 40 ++++++++++++ .github/workflows/build-and-test.yml | 42 ++++++++++++ .github/workflows/release.yml | 74 ---------------------- .github/workflows/test-no-build.yml | 18 ++++++ 4 files changed, 100 insertions(+), 74 deletions(-) create mode 100644 .github/shared/functional-tests/action.yml create mode 100644 .github/workflows/build-and-test.yml delete mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test-no-build.yml diff --git a/.github/shared/functional-tests/action.yml b/.github/shared/functional-tests/action.yml new file mode 100644 index 00000000..56f7cb6f --- /dev/null +++ b/.github/shared/functional-tests/action.yml @@ -0,0 +1,40 @@ +name: "Functional tests" +description: "Run functional tests against the app in lib/index.js" + +runs: + using: "composite" + steps: + - name: Load test key + shell: bash + id: get_key + run: | + value=$(cat src/tests/test_key_b64.txt) + echo "text=$value" >> $GITHUB_OUTPUT + + - uses: ./ + name: zipalign and Sign APK + with: + releaseDirectory: src/tests/apk-zip + signingKeyBase64: ${{ steps.get_key.outputs.text }} + alias: test_key + keyStorePassword: android + keyPassword: android + zipAlign: true + + - uses: ./ + name: Sign APK + with: + releaseDirectory: src/tests/apk + signingKeyBase64: ${{ steps.get_key.outputs.text }} + alias: test_key + keyStorePassword: android + keyPassword: android + + - uses: ./ + name: Sign AAB + with: + releaseDirectory: src/tests/aab + signingKeyBase64: ${{ steps.get_key.outputs.text }} + alias: test_key + keyStorePassword: android + keyPassword: android diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 00000000..d2a3a447 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,42 @@ +name: "Build and test" + +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + build-and-test: + runs-on: ubuntu-latest + name: Build and test + + steps: + - uses: actions/checkout@v4 + name: Checkout + + - name: Install dependencies + run: npm install + + - name: Build + run: npm run build + + - name: eslint + run: npx eslint + + - name: Ensure no pending Git changes + run: | + GIT_STATUS=$(git status --porcelain) + if [[ -n $GIT_STATUS ]]; then + echo "There are pending Git changes after running the build. Did you forget to commit the .js files?" + echo "$GIT_STATUS" + exit 1 + fi + + - name: Run unit tests + run: npm run test + + - uses: "./.github/shared/functional-tests" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 50b33a74..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,74 +0,0 @@ -name: "Test" - -on: - push: - branches: - - main - pull_request: - branches: - - main - workflow_dispatch: - -jobs: - test: - runs-on: ubuntu-latest - name: Test action - - steps: - - uses: actions/checkout@v4 - name: Checkout - - - name: Install dependencies - run: npm install - - - name: Build - run: npm run build - - - name: eslint - run: npx eslint - - - name: Ensure no pending Git changes - run: | - GIT_STATUS=$(git status --porcelain) - if [[ -n $GIT_STATUS ]]; then - echo "There are pending Git changes after running the build. Did you forget to commit the .js files?" - echo "$GIT_STATUS" - exit 1 - fi - - - name: Run tests - run: npm run test - - - name: Load test key - id: get_key - run: | - value=$(cat src/tests/test_key_b64.txt) - echo "text=$value" >> $GITHUB_OUTPUT - - - uses: ./ - name: zipalign and Sign APK - with: - releaseDirectory: src/tests/apk-zip - signingKeyBase64: ${{ steps.get_key.outputs.text }} - alias: test_key - keyStorePassword: android - keyPassword: android - zipAlign: true - - - uses: ./ - name: Sign APK - with: - releaseDirectory: src/tests/apk - signingKeyBase64: ${{ steps.get_key.outputs.text }} - alias: test_key - keyStorePassword: android - keyPassword: android - - - uses: ./ - name: Sign AAB - with: - releaseDirectory: src/tests/aab - signingKeyBase64: ${{ steps.get_key.outputs.text }} - alias: test_key - keyStorePassword: android - keyPassword: android diff --git a/.github/workflows/test-no-build.yml b/.github/workflows/test-no-build.yml new file mode 100644 index 00000000..6217f7ec --- /dev/null +++ b/.github/workflows/test-no-build.yml @@ -0,0 +1,18 @@ +name: "Test compiled action" + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + name: Test action + + steps: + - uses: actions/checkout@v4 + name: Checkout + + - uses: "./.github/shared/functional-tests"