diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b25a53f5..421100cf 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -16,7 +16,8 @@ updates: # # Limit the amout of open PR's (default = 5, disabled = 0, security updates are not impacted) # open-pull-requests-limit: 5 # - # Enable version updates for Docker + #Since we use the lts-alpine image in the Dockerfile this is currently not needed + # # Enable version updates for Docker #- package-ecosystem: "docker" # # Look for a `Dockerfile` in the `root` directory # directory: "/" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 38756d2e..2ebf5a60 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,4 @@ -name: Automated tests +name: CI on: push: @@ -13,76 +13,94 @@ on: - '**.md' jobs: - test: - name: Run tests + + node: + name: Node.js (${{matrix.node_version_file}}) + runs-on: ubuntu-latest strategy: fail-fast: false matrix: - node_version: - - 16 - - 18 - - runs-on: ubuntu-latest + node_version_file: + - .nvmrc + - package.json steps: - - name: Checkout + - name: Checkout repository uses: actions/checkout@v4 - - name: Setup + - name: Setup Node.js from ${{matrix.node_version_file}} file uses: actions/setup-node@v4 with: - node-version: ${{matrix.node_version}} + node-version-file: ${{matrix.node_version_file}} + cache: npm + cache-dependency-path: 'package-lock.json' - - name: Install - run: npm ci + - name: Install modules from package.json + run: npm clean-install --ignore-scripts + + - name: Run postinstall scripts + run: npm run postinstall - - name: Test - run: npm test + - name: Run tests + run: npm run test:js docker: - name: Test docker image - + name: Docker runs-on: ubuntu-latest - continue-on-error: true steps: - - name: Checkout + - name: Checkout repository uses: actions/checkout@v4 - - name: Build + - name: Build image from Dockerfile run: docker build --tag dr4ft-app . - - name: Run - run: docker run -dp 1337:1337 dr4ft-app + - name: Run container from image + run: docker run --detach --name dr4ft -p 1337:1337 dr4ft-app + + # TODO: Extend this and test e.g. creating a game via API + - name: Access dr4ft page + run: wget http://localhost:1337 - - name: Show info + - name: Show information run: | docker --version echo - docker ps -a + docker images dr4ft-app + echo + docker ps + echo + echo "Node version (dr4ft-app image)" + docker run dr4ft-app node --version echo - docker images + docker top dr4ft lint: - name: Run ESLint - + name: ESLint runs-on: ubuntu-latest steps: - - name: Checkout + - name: Checkout repository uses: actions/checkout@v4 - - name: Setup + - name: Setup Node.js from .nvmrc file uses: actions/setup-node@v4 with: - node-version: 18 + node-version-file: '.nvmrc' + cache: npm + cache-dependency-path: 'package-lock.json' - - name: Install - run: npm ci --ignore-scripts + - name: Install ESLint + run: npm clean-install eslint --ignore-scripts - name: Run ESLint - run: npm run lint + run: | + echo "Node version" + node --version + echo "ESLint version" + npx eslint --version + npm run lint diff --git a/Dockerfile b/Dockerfile index 0fabc240..dcbda842 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,8 +14,11 @@ RUN adduser -S dr4ftuser RUN chown dr4ftuser -R . USER dr4ftuser -# Install the dependencies -RUN npm ci +# Install dependencies +RUN npm clean-install --ignore-scripts + +# Run postinstall scripts +RUN npm run postinstall # Publish the port 1337 EXPOSE 1337 diff --git a/README.md b/README.md index 8915a754..04ff5fb9 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ # dr4ft [![Discord](https://img.shields.io/discord/224178957103136779?label=Discord&logo=discord&logoColor=white&color=7289da)](https://mtgjson.com/discord) -*dr4ft* is a NodeJS based web-application that simulates draft and sealed format between players and/or bots. -Most of MTG sets are playable thanks to MTGJson support. We follow as much as possible the rules that determine how a real booster is created. +*dr4ft* is a Node.js based web-application that simulates draft and sealed format between players and/or bots. +Most of MTG sets are playable thanks to MTGJSON support. We follow as much as possible the rules that determine how a real booster is created. The application provides the following features: @@ -64,10 +64,9 @@ It supports all their features, and many more. ### Native -1) Install [Node.js](https://nodejs.org/en/download/) >= 16.0.0. Alternatively, install [nvm](https://github.com/nvm-sh/nvm) and then run `nvm use` in this repo, which will install the correct Node version for this repo as defined in the `.nvmrc` file. +1) Install [Node.js](https://nodejs.org/en/download/) >= 16.0.0
Alternatively, install [nvm](https://github.com/nvm-sh/nvm) and run `nvm use` in the project root to install a correct Node version for this repo as defined in the [`.nvmrc`](.nvmrc) file. 2) Run
`$ npm ci`
-`$ npm run build`
`$ npm start` 3) Visit [http://localhost:1337](http://localhost:1337) @@ -86,17 +85,17 @@ You can also create a Docker image and run the app in a container: ### Start Server -`npm start` -This command start the server +- `npm start` +This command starts the server. -`npm run download_allsets` -This command downloads all sets from MTGJson and integrates them. +- `npm run download_allsets` +This command downloads all sets from [MTGJSON](https://mtgjson.com) and integrates them. -`npm run update_database` -This command downloads integrates all files previously downloaded from MTGJson. +- `npm run update_database` +This command downloads and integrates all files previously downloaded from MTGJSON. -`npm run download_booster_rules` - download and parse booster generation rules from [magic-sealed-data](https://github.com/taw/magic-sealed-data) +- `npm run download_booster_rules` +This command downloads and parses booster generation rules from [taw/magic-sealed-data](https://github.com/taw/magic-sealed-data) ## Development Notes @@ -140,6 +139,7 @@ Pull requests are welcome. For major changes, please open an issue first to disc Please make sure to update tests as appropriate. +

The project is unaffiliated with Wizards of the Coast, and is licensed under the MIT license.