Skip to content

Commit

Permalink
Set '3.1.2' as default version. (#103)
Browse files Browse the repository at this point in the history
Add versions: '3.1-rc1', '3.1.1', '3.1.2'.

Signed-off-by: Sven Pfennig <s.pfennig@reply.de>
Co-authored-by: Yevhen Fabizhevskyi <fabasoad@gmail.com>

Co-authored-by: Yevhen Fabizhevskyi <fabasoad@gmail.com>
  • Loading branch information
0xE282B0 and fabasoad committed Jul 29, 2022
1 parent 05a938e commit 369a0cc
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/functional-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest']
version: ['3.0-rc1']
version: ['3.1.2', '3.0-rc1', '3.1-rc1', '3.1.1']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ This action sets up a [GnuCOBOL](https://en.wikipedia.org/wiki/COBOL) programmin

## Inputs

| Name | Required | Description | Default | Possible values |
|---------|----------|------------------------------------------------------|-----------|-----------------|
| version | No | GnuCOBOL version. Currently supports `3.0-rc1` only. | `3.0-rc1` | `3.0-rc1` |
| Name | Required | Description | Default | Possible values |
|---------|----------|-------------------|-----------|---------------------------------------|
| version | No | GnuCOBOL version. | `3.1.2` |`3.0-rc1`, `3.1-rc1`, `3.1.1`, `3.1.2` |

## Example usage

Expand Down
45 changes: 23 additions & 22 deletions __tests__/test-installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const {

const fixture = ['Darwin', 'Windows_NT'];

const validVersion = '3.0-rc1';
const validVersions = ['3.1.2', '3.0-rc1', '3.1-rc1', '3.1.1'];
const invalidVersion = 'y50pgz2b';

describe('Test Installer class', () => {
Expand All @@ -29,21 +29,22 @@ describe('Test Installer class', () => {
osTypeStub = sinon.stub(os, 'type');
});

it('should build correct exec file name for Linux OS', () => {
osTypeStub.returns('Linux');
itParam('should build correct exec file name for Linux OS (${value})',
validVersions, (validVersion) => {
osTypeStub.returns('Linux');

const installer = new Installer(validVersion);
const installer = new Installer(validVersion);

const expected = 'install-cobol-linux.sh';
const actual = installer._execFileName();
assert.equal(expected, actual);
});
const expected = 'install-cobol-linux.sh';
const actual = installer._execFileName();
assert.equal(expected, actual);
});

itParam('should not build exec file name for ${value} OS', fixture,
(osType) => {
osTypeStub.returns(osType);

const installer = new Installer(validVersion);
const installer = new Installer(validVersions[0]);

try {
installer._execFileName();
Expand All @@ -56,26 +57,26 @@ describe('Test Installer class', () => {
assert.Throw();
});

it('should install correctly for Linux OS', async () => {
const version = validVersion;
const execFileName = 'install-cobol-linux.sh';
itParam('should install correctly for Linux OS (${value})',
validVersions, async (version) => {
const execFileName = 'install-cobol-linux.sh';

osTypeStub.returns('Linux');
osTypeStub.returns('Linux');

const installer = new Installer(version);
await installer.install();
const installer = new Installer(version);
await installer.install();

execExecStub.calledOnceWith(
path.join(__dirname, execFileName),
[version]
);
fsChmodSyncStub.calledOnceWith(path.join(__dirname, execFileName), '777');
});
execExecStub.calledOnceWith(
path.join(__dirname, execFileName),
[version]
);
fsChmodSyncStub.calledOnceWith(path.join(__dirname, execFileName), '777');
});

itParam('should not install for ${value} OS', fixture, async (osType) => {
osTypeStub.returns(osType);

const installer = new Installer(validVersion);
const installer = new Installer(validVersions[0]);
try {
await installer.install();
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ inputs:
version:
description: 'GnuCOBOL version.'
required: false
default: '3.0-rc1'
default: '3.1.2'
runs:
using: 'node12'
main: 'dist/index.js'
4 changes: 2 additions & 2 deletions dist/index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/install-cobol-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ sudo apt-get -y install iproute2

# download and install open-cobol for depencies (libcob >= 4.0)
sudo apt-get -y install ranger autoconf build-essential
curl -sLk https://sourceforge.net/projects/open-cobol/files/gnu-cobol/3.0/gnucobol-"${1}".tar.gz | tar xz
cd gnucobol-"${1}" && ./configure --prefix=/usr && sudo make && sudo make install && sudo ldconfig && cd /tmp/ && rm -rf ./*
curl -sLk https://sourceforge.net/projects/open-cobol/files/gnu-cobol/"${1}"/gnucobol-"${2}".tar.gz | tar xz
cd gnucobol-"${2}" && ./configure --prefix=/usr && sudo make && sudo make install && sudo ldconfig && cd /tmp/ && rm -rf ./*
sudo apt-get -y --purge autoremove

sudo chmod +x /home/cobol/cobol-unit-test/run-ut
Expand Down
5 changes: 3 additions & 2 deletions src/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Installer {
this.version = version;
this.baseDir = baseDir;
this.logger = new Logger('Installer');
this.SUPPORTED_VERSIONS = ['3.0-rc1'];
this.SUPPORTED_VERSIONS = ['3.0-rc1', '3.1-rc1', '3.1.1', '3.1.2'];
this.EXEC_FILE_NAME = 'install-cobol-linux.sh';
}

Expand All @@ -42,11 +42,12 @@ class Installer {
`Version ${this.version} is not supported.`
);
}
const sfFolder = this.version.match(/(\d\.\d).*/)[1]
const execFileName = path.join(this.baseDir, this._execFileName());
this.logger.info(`Changing permissions to 777 for ${execFileName}...`);
fs.chmodSync(execFileName, '777');
this.logger.info(`Running ${execFileName}...`);
await exec.exec(execFileName, [this.version]);
await exec.exec(execFileName, [sfFolder, this.version]);
this.logger.info('Installation successfully finished.');
}
}
Expand Down

0 comments on commit 369a0cc

Please sign in to comment.