Skip to content

Esm

Esm #697

Workflow file for this run

# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: CI
on:
push:
branches: [ main ]
tags: ['*']
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [ '^22.14.0' ]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
# extract repository name
- if: github.event_name == 'pull_request'
run: echo "REPO_NAME=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_ENV
- if: github.event_name != 'pull_request'
run: echo "REPO_NAME=${GITHUB_REPOSITORY}" >> $GITHUB_ENV
# extract branch name
- if: github.event_name == 'pull_request'
run: echo "BRANCH_NAME=${GITHUB_HEAD_REF}" >> $GITHUB_ENV
- if: github.event_name != 'pull_request'
run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
# print repository name
- name: Get repository name
run: echo 'The repository name is' $REPO_NAME
# print branch name
- name: Get branch name
run: echo 'The branch name is' $BRANCH_NAME
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
# test code
- run: npm run standard
- run: npm run validate
- run: npm run c8
# Test global install of the package
- run: npm pack .
- run: npm install -g solid-server-*.tgz
- name: Save build
# if: matrix.node-version == '20.x'
uses: actions/upload-artifact@v5
with:
name: build
path: |
.
!node_modules
retention-days: 1
test-suite:
needs: build
runs-on: ubuntu-latest
steps:
# Run the Solid test-suite
- run: bash test/surface/run-solid-test-suite.sh $BRANCH_NAME $REPO_NAME
# The pipeline automate publication to npm, so that the docker build gets the correct version
npm-publish-build:
needs: [build, test-suite]
name: Publish to npm
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v6
with:
name: build
- uses: actions/setup-node@v6
with:
node-version: 20.x
- uses: rlespinasse/github-slug-action@v3.x
- name: Append commit hash to package version
run: 'sed -i -E "s/(\"version\": *\"[^\"]+)/\1-${GITHUB_SHA_SHORT}/" package.json'
- name: Disable pre- and post-publish actions
run: 'sed -i -E "s/\"((pre|post)publish)/\"ignore:\1/" package.json'
- uses: JS-DevTools/npm-publish@v4.1.0
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
with:
token: ${{ secrets.NPM_TOKEN }}
tag: ${{ env.GITHUB_REF_SLUG }}
npm-publish-latest:
needs: [build, test-suite, npm-publish-build]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/download-artifact@v6
with:
name: build
- uses: actions/setup-node@v6
with:
node-version: 20.x
- name: Disable pre- and post-publish actions
run: 'sed -i -E "s/\"((pre|post)publish)/\"ignore:\1/" package.json'
- uses: JS-DevTools/npm-publish@v4.1.0
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
with:
token: ${{ secrets.NPM_TOKEN }}
tag: latest
# This job will only dockerize solid-server@latest / solid-server@<tag-name> from npmjs.com!
docker-hub:
needs: build
name: Publish to docker hub
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: olegtarasov/get-tag@v2.1
id: tagName
with:
tagRegex: "v?(?<version>.*)"
- name: Lint dockerfile
working-directory: docker-image
run: pwd && ls -lah && make lint
- name: Run tests
working-directory: docker-image
run: SOLID_SERVER_VERSION=${{ steps.tagName.outputs.version }} make test
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: nodesolidserver/node-solid-server
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./docker-image/src
build-args: SOLID_SERVER_VERSION=${{ steps.tagName.outputs.version }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}