diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml new file mode 100644 index 0000000..dd4ad75 --- /dev/null +++ b/.github/workflows/check-dist.yml @@ -0,0 +1,51 @@ +# `dist/index.js` is a special file in Actions. +# When you reference an action with `uses:` in a workflow, +# `index.js` is the code that will run. +# For our project, we generate this file through a build process from other source files. +# We need to make sure the checked-in `index.js` actually matches what we expect it to be. +name: Check dist/ + +on: + push: + branches: + - main + paths-ignore: + - '**.md' + pull_request: + paths-ignore: + - '**.md' + workflow_dispatch: + +jobs: + check-dist: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set Node.js 12.x + uses: actions/setup-node@v2.4.1 + with: + node-version: 12.x + + - name: Install dependencies + run: npm ci + + - name: Rebuild the dist/ directory + run: npm run build + + - name: Compare the expected and actual dist/ directories + run: | + if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then + echo "Detected uncommitted changes after build. See status below:" + git diff + exit 1 + fi + id: diff + + # If index.js was different than expected, upload the expected version as an artifact + - uses: actions/upload-artifact@v2 + if: ${{ failure() && steps.diff.conclusion == 'failure' }} + with: + name: dist + path: dist/ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..df389e6 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,114 @@ +name: 'build-test' +on: # rebuild any PRs and main branch changes + pull_request: + push: + branches: + - main + - 'releases/*' + +jobs: + build: # make sure build/ci work properly + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: | + npm install + - run: | + npm run all + test: # make sure the action works on a clean machine without building + name: ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + version: [latest, nightly, trunk] + java-version: ['11'] + components: ['native-image'] + os: [macos-latest, windows-latest, ubuntu-latest] + include: + - version: '21.3.0' + java-version: '17' + components: 'native-image' + os: ubuntu-18.04 + - version: '21.3.0' + java-version: '17' + components: 'native-image' + os: macos-11 + - version: '21.3.0' + java-version: '17' + components: 'native-image' + os: windows-2022 + - version: '21.3.0' + java-version: '17' + components: 'native-image' + os: windows-2016 + steps: + - uses: actions/checkout@v2 + - name: Run setup-graalvm action + uses: ./ + with: + version: ${{ matrix.version }} + java-version: ${{ matrix.java-version }} + components: ${{ matrix.components }} + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Check environment + run: | + echo "GRAALVM_HOME: $GRAALVM_HOME" + echo "JAVA_HOME: $JAVA_HOME" + java --version + native-image --version + if: runner.os != 'Windows' + - name: Check Windows environment + run: | + echo "GRAALVM_HOME: $env:GRAALVM_HOME" + echo "JAVA_HOME: $env:JAVA_HOME" + java --version + native-image.cmd --version + if: runner.os == 'Windows' + test-additional: + name: Extensive tests on ubuntu-latest + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run setup-graalvm action + uses: ./ + with: + version: 'latest' + java-version: '17' + components: 'espresso,llvm-toolchain,native-image,nodejs,python,R,ruby,wasm' + set-java-home: 'false' + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Check environment + run: | + echo "GRAALVM_HOME: $GRAALVM_HOME" + echo "JAVA_HOME: $JAVA_HOME" + [[ "$GRAALVM_HOME" != "$JAVA_HOME" ]] || exit 12 + [[ $(which java) == *"graalvm"* ]] || exit 23 + java --version + java -truffle --version + gu --version + gu list + [[ $(which lli) == *"graalvm"* ]] || exit 34 + lli --version + native-image --version + [[ $(which node) == *"graalvm"* ]] || exit 45 + node --version + graalpython --version + [[ $(which R) == *"graalvm"* ]] || exit 56 + R --version + truffleruby --version + wasm --version + - name: Build HelloWorld.java with Native Image + run: | + echo 'public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }' > HelloWorld.java + javac HelloWorld.java + native-image HelloWorld + ./helloworld + # [GR-36108]: Liquid does not build on TruffleRuby + # - name: Build Shopify/liquid with TruffleRuby + # run: | + # [[ $(which bundle) == *"graalvm"* ]] || exit 57 + # git clone --depth 1 https://github.com/Shopify/liquid.git + # pushd liquid > /dev/null + # bundle install --jobs=3 --retry=3 --path=vendor/bundle + # bundle exec rake + # popd > /dev/null