diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..bd56c98 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,97 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - ** + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - uses: actions/setup-node@v3 + with: + node-version: 16 + cache: 'npm' + - name: Install + run: npm install + - name: lint + run: npm run lint + + test_production: + name: Test production + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - uses: actions/setup-node@v3 + with: + node-version: 16 + cache: 'npm' + - name: Install + run: npm install + - name: Build + run: npm run build + - name: Run integration + run: npm run test:integration + - name: Run tests + run: npm run test:browser + + test_linux: + name: Test on Linux with Node ${{ matrix.node }} + runs-on: ubuntu-latest + strategy: + matrix: + node: [16, 18, 20] + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + cache: 'npm' + - name: Install + run: npm install + - name: Run tests + run: npm run test:node + + test_macos: + name: Test on MacOS with Node 16 + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - uses: actions/setup-node@v3 + with: + node-version: 16 + cache: 'npm' + - name: Install + run: npm install + - name: Run tests + run: npm run test:node + + test_windows: + name: Test on Windows with Node 16 + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - uses: actions/setup-node@v3 + with: + node-version: 16 + cache: 'npm' + - name: Install + run: npm install + - name: Run tests + run: npm run test:node diff --git a/.npmignore b/.npmignore index 4e5d0be..806aa78 100644 --- a/.npmignore +++ b/.npmignore @@ -1,8 +1,8 @@ +.github/ src/ test/ scripts/ .nyc_output/ -.travis.yml .gitmodules .eslintrc .editorconfig diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3da8313..0000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: node_js -node_js: - - "12" - - "14" - -install: - - npm install - -script: - - npm run build - - npm run lint - - npm test - - npm run test:integration diff --git a/karma.conf.js b/karma.conf.js index b89077f..9267a93 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,62 +1,51 @@ process.env.CHROME_BIN = require('puppeteer').executablePath() -module.exports = function(config) { +module.exports = function (config) { config.set({ - // base path that will be used to resolve all patterns (eg. files, exclude) basePath: '', - // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['mocha'], - // list of files / patterns to load in the browser - files: [ - 'dist/index.iife.js', - 'browser-test/*.js' - ], - + files: ['dist/index.iife.js', 'browser-test/*.js'], // list of files / patterns to exclude - exclude: [ - ], - + exclude: [], // preprocess matching files before serving them to the browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor - preprocessors: { - }, - + preprocessors: {}, // test results reporter to use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter reporters: ['progress'], - // web server port port: 9876, - // enable / disable colors in the output (reporters and logs) colors: true, - // level of logging // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG logLevel: config.LOG_INFO, - // enable / disable watching file and executing tests whenever any file changes autoWatch: true, - // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['ChromeHeadless'], - + browsers: ['ChromeHeadlessNoSandbox'], + customLaunchers: { + ChromeHeadlessNoSandbox: { + base: 'ChromeHeadless', + flags: ['--no-sandbox'], + }, + }, // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits @@ -64,6 +53,6 @@ module.exports = function(config) { // Concurrency level // how many browser should be started simultaneous - concurrency: Infinity + concurrency: Infinity, }) } diff --git a/test-integration/test.js b/test-integration/test.js index 7bc0fb4..b6cc183 100644 --- a/test-integration/test.js +++ b/test-integration/test.js @@ -7,7 +7,7 @@ const parser = require('..') describe('integration', function () { it('parses test file correctly', function () { const content = fs.readFileSync( - path.join(__dirname, '..', 'test', 'test.sol') + path.join(__dirname, '..', 'antlr', 'test.sol') ) parser.parse(content.toString()) })