Skip to content

Commit

Permalink
migrate from travis-ci to github actions (#61)
Browse files Browse the repository at this point in the history
* migrate from travis-ci to github actions

* update maintainer's guide with info on composer usage

* fix hhvm running at wrong version

* does this work

* how about this

* uhh how about this

* support HHVM 4.80

* fix unit tests on 4.80

* fix lint errors

* drop 4.56 from this branch
  • Loading branch information
Scott Sandler authored Jan 5, 2021
1 parent c2e22dc commit 6f18c3b
Show file tree
Hide file tree
Showing 23 changed files with 187 additions and 87 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Continuous Integration
on:
pull_request:
jobs:
build:
name: HHVM ${{matrix.hhvm}} - ${{matrix.os}}
strategy:
# Run tests on all OS's and HHVM versions, even if one fails
fail-fast: false
matrix:
os: [ ubuntu ]
hhvm:
- '4.80'
runs-on: ${{matrix.os}}-latest
steps:
- uses: actions/checkout@v2
- name: Install Composer
run: .github/workflows/install-composer.sh --install-dir=${{runner.temp}}
- name: Install HHVM (apt)
if: matrix.os == 'ubuntu'
run: |
set -ex
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get install -y software-properties-common apt-transport-https
sudo apt-key add .github/workflows/hhvm.gpg.key
if [ "${{matrix.hhvm}}" = "nightly" ]; then
sudo add-apt-repository https://dl.hhvm.com/ubuntu
sudo apt-get install -y hhvm-nightly
elif [ "${{matrix.hhvm}}" = "latest" ]; then
sudo add-apt-repository https://dl.hhvm.com/ubuntu
sudo apt-get install -y hhvm
else
DISTRO=$(lsb_release --codename --short)
sudo add-apt-repository \
"deb https://dl.hhvm.com/ubuntu ${DISTRO}-${{matrix.hhvm}} main"
sudo apt remove hhvm
sudo apt-get install -y hhvm
fi
- name: Inspect HHVM and Hack versions
run: |
hhvm --version
hh_client --version
- name: Create branch for version alias
run: git checkout -b CI_current_pull_request
- name: Install project dependencies
run: php ${{runner.temp}}/composer.phar install
- name: Typecheck
run: hh_client
- name: Run tests
run: vendor/bin/hacktest tests/
- name: Run lint
if: matrix.hhvm != 'nightly'
run: vendor/bin/hhast-lint
36 changes: 36 additions & 0 deletions .github/workflows/hhvm.gpg.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1

mQINBFn8koEBEAC2tPtkphj8gZYHI9mTNUHfQalDo+MNWTGUTNB42asjhTNjipzM
VSxjaZSl5cMLg5YCRuT0AbSIe529FH23yEElc03cGVGgoEnmXtE4+2v7Xa30wCGO
5oUxKfbVatsxEs1y8QEr5Gt+CUFmsApOKgiZq0MsPYmFAuC9CbWdXYa8+E00bXOa
cHCpe+GncCxQmExm7TlrUnURnf3RnNWSEkuPKED/aVggzxNVN6RgRRm4ssZJasM3
TwoI1nVysO5jMfPClvupYscoktO44HBZzH2EeEdpjSV+toD3aZCbmWzXyZjogrFN
j4k5Mme0Xqr4DvRPk5M9SxcQASsCQ8VTyu+ZBUG6zJbddLDEA1BMNIZOG5MyX58O
zed255Q85SAyjHu8pltkfGLd56+MYsckpHaBPMFoCFM4iPcpXOlgcU96pdXJbrR2
mjYI4Le9qRJYYP2kGPkopPwK8nbZJ5Wr7xaclxEc/ODH3mv57KJD7lzmwpnvvmsn
kR/wUHOqwrXojp/oZCUK8KembLiT+MMkY3bne+IY9ef/1qwu4flVBP1CpoaMQEwh
dqzihfwyQ+57ATZHJaj8V9pKAxWh/Df4iFN5mMWA15eBLhRMbAWKJIoLQLcCYwBF
gH3HiO34/uQUHaX6VhRHllA38WUoZNhKmw/Kcd/FDQWlbzbgmI89LJEJuwARAQAB
tC1ISFZNIFBhY2thZ2UgU2lnbmluZyA8b3BlbnNvdXJjZStoaHZtQGZiLmNvbT6J
Ak4EEwEIADgWIQQFg0HGj8jeYBfXdaG0ESWF04brlAUCWfySgQIbAwULCQgHAgYV
CAkKCwIEFgIDAQIeAQIXgAAKCRC0ESWF04brlMp8D/4ia7wLi6OQEtR8uPIrtCdg
ClHvXTX0zihHPDomn77lRSfq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UBLIC KEY BLOCK-----
19 changes: 19 additions & 0 deletions .github/workflows/install-composer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

# From https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md

EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"

if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
then
>&2 echo 'ERROR: Invalid installer checksum'
rm composer-setup.php
exit 1
fi

php composer-setup.php "$@"
RESULT=$?
rm composer-setup.php
exit $RESULT
21 changes: 0 additions & 21 deletions .travis.sh

This file was deleted.

18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"hhvm/hhvm-autoload": "^2.0.4|^3"
},
"require-dev": {
"hhvm/hhast": "^4.0.5",
"hhvm/hhast": "^4.80",
"facebook/fbexpect": "^2.2.0",
"hhvm/hacktest": "^1.3|^2.0"
}
Expand Down
11 changes: 11 additions & 0 deletions maintainers_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ this project. If you use this package within your own software as is but don't p

## Tasks

### Setup

Install [Composer](https://getcomposer.org/) and PHP. Use PHP to run composer and install dependencies in this working copy. This will create and populate the `vendor/` directory. Note that composer cannot be run with HHVM.

```
# if composer installed locally
/usr/bin/php composer.phar install
# if installed globally
/usr/bin/php /usr/local/bin/composer install
```

### Testing

Run unit tests locally using `vendor/bin/hacktest tests/`. Tests are also run automatically on all branches using [Travis CI](https://travis-ci.org/slackhq/hack-sql-fake).
Expand Down
1 change: 1 addition & 0 deletions src/AsyncMysql/AsyncMysqlClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static function setPoolsConnectionLimit(int $_limit): void {}
string $_password,
int $_timeout_micros = -1,
?\MySSLContextProvider $_ssl_provider = null,
int $_tcp_timeout_micros = 0,
): Awaitable<\AsyncMysqlConnection> {
return new AsyncMysqlConnection($host, $port, $dbname);
}
Expand Down
1 change: 1 addition & 0 deletions src/AsyncMysql/AsyncMysqlConnectionPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function reset(): void {
string $_password,
int $_timeout_micros = -1,
string $_caller = '',
int $_tcp_timeout_micros = 0,
): Awaitable<AsyncMysqlConnection> {
$this->connectionsRequest++;
if (C\contains_key(static::$pool, $host)) {
Expand Down
8 changes: 4 additions & 4 deletions src/BuildSchemaCLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function getSupportedOptions(): vec<CLIOptions\CLIOption> {

if (C\is_empty($this->getArguments())) {
$program = $this->getArgv()[0];
await $terminal->getStdout()->writeAsync(<<<EOT
await $terminal->getStdout()->writeAllAsync(<<<EOT
Usage: {$program} [--name DB_SCHEMA] [files...] > schema.hack
Expand All @@ -49,7 +49,7 @@ protected function getSupportedOptions(): vec<CLIOptions\CLIOption> {
if ($match === null) {
/* HHAST_IGNORE_ERROR[DontAwaitInALoop] */
await $terminal->getStderr()
->writeAsync("Expected file name matching [database_name].sql, {$file} does not match");
->writeAllAsync("Expected file name matching [database_name].sql, {$file} does not match");
return 1;
}

Expand All @@ -59,7 +59,7 @@ protected function getSupportedOptions(): vec<CLIOptions\CLIOption> {

if ($contents === false) {
/* HHAST_IGNORE_ERROR[DontAwaitInALoop] */
await $terminal->getStderr()->writeAsync("File could not be loaded: {$contents}");
await $terminal->getStderr()->writeAllAsync("File could not be loaded: {$contents}");
return 1;
}

Expand Down Expand Up @@ -105,7 +105,7 @@ protected function getSupportedOptions(): vec<CLIOptions\CLIOption> {
.
$generated;

await $terminal->getStdout()->writeAsync($generated);
await $terminal->getStdout()->writeAllAsync($generated);
return 0;
}
}
4 changes: 2 additions & 2 deletions src/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public static function log(Verbosity $verbosity, string $message): void {

protected static function write(string $message): void {
if (self::$handle is nonnull) {
/*HHAST_FIXME[DontUseAsioJoin]*/
\HH\Asio\join(self::$handle->writeAsync($message));
/*HHAST_FIXME[DontUseAsioJoin]*/
\HH\Asio\join(self::$handle->writeAllAsync($message));
} else {
\error_log($message);
}
Expand Down
13 changes: 8 additions & 5 deletions src/Parser/CreateTableParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,7 @@ private function nextTokenIs(vec<string> $tokens, string $val): bool {
return Str\uppercase($tokens[0]) === $val;
}
private function parseCreateDefinition(
inout vec<string> $tokens,
): shape(
private function parseCreateDefinition(inout vec<string> $tokens): shape(
'fields' => vec<parsed_field>,
'indexes' => vec<parsed_index>,
) {
Expand Down Expand Up @@ -521,6 +519,9 @@ private function parseFieldOrKey(
# not currently handled
return;
default:
# any other tokens fall through to be parsed below
break;
}
$fields[] = $this->parseField($tokens);
Expand Down Expand Up @@ -881,8 +882,10 @@ private function extractTokens(string $sql, vec<(int, int)> $source_map): vec<st
# Extend the length of the first token to include everything
# up through the last in the sequence.
$j = $i + C\count($list) - 1;
$out_map[] =
tuple($source_map[$i][0], ($source_map[$j][0] - $source_map[$i][0]) + $source_map[$j][1]);
$out_map[] = tuple(
$source_map[$i][0],
($source_map[$j][0] - $source_map[$i][0]) + $source_map[$j][1],
);
$i = $j + 1;
$found = true;
Expand Down
2 changes: 1 addition & 1 deletion tests/DeleteQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ final class DeleteQueryTest extends HackTest {
public static async function beforeFirstTestAsync(): Awaitable<void> {
static::$conn = await SharedSetup::initAsync();
// block hole logging
Logger::setHandle(new \Facebook\CLILib\TestLib\StringOutput());
Logger::setHandle(new \HH\Lib\IO\MemoryHandle());
}

<<__Override>>
Expand Down
2 changes: 1 addition & 1 deletion tests/InsertQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class InsertQueryTest extends HackTest {
$pool = new AsyncMysqlConnectionPool(darray[]);
static::$conn = await $pool->connect('example', 1, 'db1', '', '');
// black hole logging
Logger::setHandle(new \Facebook\CLILib\TestLib\StringOutput());
Logger::setHandle(new \HH\Lib\IO\MemoryHandle());
}

<<__Override>>
Expand Down
2 changes: 1 addition & 1 deletion tests/JSONFunctionTest.hack
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class JSONFunctionTest extends HackTest {
public static async function beforeFirstTestAsync(): Awaitable<void> {
static::$conn = await SharedSetup::initAsync();
// block hole logging
Logger::setHandle(new \Facebook\CLILib\TestLib\StringOutput());
Logger::setHandle(new \HH\Lib\IO\MemoryHandle());
}

<<__Override>>
Expand Down
7 changes: 4 additions & 3 deletions tests/JoinQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ final class JoinQueryTest extends HackTest {
public async function testLeftJoin(): Awaitable<void> {
$conn = static::$conn as nonnull;
$results =
await $conn->query('SELECT id, table_4_id FROM table3 LEFT OUTER JOIN association_table ON id=table_3_id');
$results = await $conn->query(
'SELECT id, table_4_id FROM table3 LEFT OUTER JOIN association_table ON id=table_3_id',
);
expect($results->rows())->toBeSame(vec[
dict['id' => 1, 'table_4_id' => 1000],
dict['id' => 1, 'table_4_id' => 1001],
Expand Down Expand Up @@ -151,7 +152,7 @@ final class JoinQueryTest extends HackTest {
public static async function beforeFirstTestAsync(): Awaitable<void> {
static::$conn = await SharedSetup::initAsync();
// block hole logging
Logger::setHandle(new \Facebook\CLILib\TestLib\StringOutput());
Logger::setHandle(new \HH\Lib\IO\MemoryHandle());
}
<<__Override>>
Expand Down
2 changes: 1 addition & 1 deletion tests/MultiQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ final class MultiQueryTest extends HackTest {
public static async function beforeFirstTestAsync(): Awaitable<void> {
static::$conn = await SharedSetup::initAsync();
// block hole logging
Logger::setHandle(new \Facebook\CLILib\TestLib\StringOutput());
Logger::setHandle(new \HH\Lib\IO\MemoryHandle());
}

<<__Override>>
Expand Down
2 changes: 1 addition & 1 deletion tests/SQLFunctionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ final class SQLFunctionTest extends HackTest {
public static async function beforeFirstTestAsync(): Awaitable<void> {
static::$conn = await SharedSetup::initAsync();
// block hole logging
Logger::setHandle(new \Facebook\CLILib\TestLib\StringOutput());
Logger::setHandle(new \HH\Lib\IO\MemoryHandle());
}

<<__Override>>
Expand Down
2 changes: 1 addition & 1 deletion tests/SelectClauseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class SelectClauseTest extends HackTest {
public static async function beforeFirstTestAsync(): Awaitable<void> {
static::$conn = await SharedSetup::initAsync();
// block hole logging
Logger::setHandle(new \Facebook\CLILib\TestLib\StringOutput());
Logger::setHandle(new \HH\Lib\IO\MemoryHandle());
}

<<__Override>>
Expand Down
Loading

0 comments on commit 6f18c3b

Please sign in to comment.